Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Minha App quebra antes de executar

Ao converter o projeto de java para kotlin ocorre algo que a app não consegue executar, e apresenta este erro.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pedroltagostini.financask/com.pedroltagostini.financask.ui.activity.ListaTransacoesActivity}: android.view.InflateException: Binary XML file line #12 in com.pedroltagostini.financask:layout/activity_lista_transacoes: Binary XML file line #2 in com.pedroltagostini.financask:layout/resumo_card: Error inflating class android.support.v7.widget.CardView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3310)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3459)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2046)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:225)
    at android.app.ActivityThread.main(ActivityThread.java:7564)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: android.view.InflateException: Binary XML file line #12 in com.pedroltagostini.financask:layout/activity_lista_transacoes: Binary XML file line #2 in com.pedroltagostini.financask:layout/resumo_card: Error inflating class android.support.v7.widget.CardView
Caused by: android.view.InflateException: Binary XML file line #2 in com.pedroltagostini.financask:layout/resumo_card: Error inflating class android.support.v7.widget.CardView
Caused by: java.lang.ClassNotFoundException: android.support.v7.widget.CardView
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:454)
    at android.view.LayoutInflater.createView(LayoutInflater.java:819)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:1237)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
    at com.pedroltagostini.financask.ui.activity.ListaTransacoesActivity.onCreate(ListaTransacoesActivity.kt:11)
    at android.app.Activity.performCreate(Activity.java:7916)
    at android.app.Activity.performCreate(Activity.java:7903)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3285)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3459)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2046)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:225)
    at android.app.ActivityThread.main(ActivityThread.java:7564)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.CardView" on path: DexPathList[[zip file "/data/app/com.pedroltagostini.financask-nMCdVm-D4eN7sf3MeqjUtA==/base.apk"],nativeLibraryDirectories=[/data/app/com.pedroltagostini.financask-nMCdVm-D4eN7sf3MeqjUtA==/lib/arm64, /system/lib64, /system/product/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:230)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 30 more
3 respostas

Este é o gradle do app: Pesei que pudesse ser algo com a versão.

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 30
    buildToolsVersion '30.0.3'

    defaultConfig {
        applicationId "com.pedroltagostini.financask"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {


    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    implementation 'com.android.support:appcompat-v7:30.0.0'
    implementation 'com.android.support:cardview-v7:30.0.0'
    implementation 'com.android.support:recyclerview-v7:30.0.0'
    implementation 'com.github.clans:fab:1.6.4'

    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'com.github.clans:fab:1.6.4'
    implementation 'com.google.android.material:material:1.3.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

Pedro, de boa?

Cara as libs estam erradas :(

Como esse curso foi gravado faz um tempinho, as libs ainda não eram com o refactor de pacotes, com o androidx, tu vai precisar trocar essas :

    implementation 'com.android.support:appcompat-v7:30.0.0'
    implementation 'com.android.support:cardview-v7:30.0.0'
    implementation 'com.android.support:recyclerview-v7:30.0.0'

Pelas que usam androidx invés de android.support

solução!

Sim, tudo certo! Obrigado