0

I tried to run an apk in android studio 3.5 and it successfully built but, in emulator it always says "App stopped" and unable to run. But the apk works well in other android phones.

In log cat the error was as below.

 2019-09-17 13:20:50.229 12155-12155/com.darkweb.android.testApp E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.darkweb.android.testApp/com.darkweb.android.testApp.HomePage}: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:647)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:965)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:995)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.darkweb.android.testApp.HomePage.onCreate(HomePage.java:59)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/constraintlayout/widget/R$styleable;
        at androidx.constraintlayout.widget.ConstraintLayout.init(ConstraintLayout.java:590)

buil.grdale file :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.darkweb.android.testApp"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    //implementation 'com.android.support:mediarouter-v7:27.1.1'

    implementation 'com.squareup.retrofit:retrofit:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    //noinspection GradleCompatible
    implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    testImplementation 'junit:junit:4.12'
    //noinspection GradleCompatible
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    implementation 'in.shadowfax:proswipebutton:1.1'
    implementation('me.omidh:rvelib:0.8.01') {
        exclude group: 'com.android.support'
        exclude module: 'appcompat-v7'
        exclude module: 'support-v4'
    }
    implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'com.google.android.material:material:1.0.0-beta01'
    implementation 'com.rom4ek:arcnavigationview:1.0.3'
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0-beta01'
    implementation 'com.google.firebase:firebase-core:12.0.1'
    implementation 'com.google.firebase:firebase-messaging:12.0.1'
    implementation 'com.github.jd-alexander:LikeButton:0.2.3'
    implementation 'com.github.qapqap:TimelineView:v1.6'
    implementation 'com.github.kobakei:MaterialFabSpeedDial:master-SNAPSHOT'
    implementation 'com.github.kobakei:MaterialFabSpeedDial:1.2.1'
    implementation 'com.crowdfire.cfalertdialog:cfalertdialog:1.0.2'
    implementation 'at.blogc:expandabletextview:1.0.5'
    implementation 'com.github.sundeepk:compact-calendar-view:3.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-rc01'

}
apply plugin: 'com.google.gms.google-services'

I tried with API level 22 and also API level 28. Both situations there was the same issue.

Sachz
  • 391
  • 5
  • 21
  • Please [edit] your question to provide the complete [stack trace](https://stackoverflow.com/a/23353174). – Mike M. Sep 18 '19 at 00:30
  • @MikeM. Done. I just edited. – Sachz Sep 18 '19 at 01:22
  • Hmm, I'm not sure if I'm following your description correctly. Are you saying that it always crashes on the emulators, and you've tried emulators of API levels 22 and 28? And, that it works perfectly fine on actual devices? If so, which API levels were those devices? Also, please provide the app's `build.gradle` file. – Mike M. Sep 18 '19 at 01:36
  • Well... this was developed by someone else and just going to continue. received APK works well in phone means that by that time it has been worked well. I imported the project to Android Studio 3.5 and trying to run it in emulator to continue the work - then it crashes. That's how I'm getting error. Seems like this has used the firebase service to store data. I'm wondering whether I have to do any such configurations as well at first without just running in emulator ... I have updated the buil.gradle file as well. – Sachz Sep 18 '19 at 02:01
  • Well, your issue is with the`ConstraintLayout`, but that particular Exception doesn't make a lot of sense to me, unless `ConstraintLayout` just recently implemented a `styleable`. Try updating your dependency from `constraintlayout:1.1.2` to `constraintlayout:1.1.3`, and cleaning/rebuilding the protect. And have a look at [this post](https://stackoverflow.com/q/54212402). – Mike M. Sep 18 '19 at 02:37
  • 1
    Hi @MikeM. I tried as per your suggestion by changing to 1.1.3 and then yes , app started to launch and got stuck like in the begining launching map showing " app is loading" (with a circle) background page was inactive but visible (used API 27). Then I closed the emulator and changed emulator API to API 28 and ran again. And.... yes then it works !!!!!!! Thank you very much !!! It works :) – Sachz Sep 18 '19 at 03:39

0 Answers0