Only Mi pad having that issue when run the app.
For fix that issues i have try
1. Uninstall the app and retry to connect that but get same error
2. Instant run is disable in my android studio
3. User Multi desk in build gradle
Other project is working from same android studio in same tab
Any one Have idea how to fix that .
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.uncommonsense, PID: 23808
java.lang.RuntimeException: Unable to instantiate application .application.ApplicationDetails: java.lang.ClassNotFoundException: Didn't find class ".application.ApplicationDetails" on path: DexPathList[[zip file "/data/app/com.test.apk"],nativeLibraryDirectories=[/data/app-lib/com.uncommonsense-1, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:507)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1270)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5028)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ucsvirtualschool.application.ApplicationDetails" on path: DexPathList[[zip file "/data/app/com.uncommonsense-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.uncommonsense-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newApplication(Instrumentation.java:975)
Application class
public class ApplicationDetails extends MultiDexApplication {
public static boolean isAppOpen = false;
private static ApplicationDetails mInstance;
public static final String TAG = ApplicationDetails.class.getSimpleName();
#Override
protected void attachBaseContext(Context base) {
MultiDex.install(this);
super.attachBaseContext(base);
}
#Override
public void onTerminate() {
// TODO Auto-generated method stub
super.onTerminate();
isAppOpen = false;
}
}
build gradle
defaultConfig {
applicationId "com.ucsvirtualschool"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables { useSupportLibrary = true }
dataBinding {
enabled = true
}
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
ndk {
abiFilters "armeabi", "x86"
}
implementation 'com.android.support:multidex:1.0.3' //for solve issue in mi tab
I would think of two things based on the code snippets you provided.
You already use the MultiDexApplication so you don't need to override the attachBaseContext method
It might happen, but very unlikely that the ApplicationDetails class doesn't make it to the first dex file and that's why the app is crashing. You could try to declare the class to be required to be in the very first dex file. Declare classes required in the primary dex file
Maybe you can try this: complete the application name ".application.ApplicationDetails" with "com.ucsvirtualschool.application.ApplicationDetails" in your in AndroidManifest.xml.
<application
android:name="com.ucsvirtualschool.application.ApplicationDetails"
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:allowBackup">
Related
I made a simple app with a webview and published it to the playstore - everything worked fine. Recently i updated the ip of the webview, changed the version code, generated a signed apk and re-uploaded to playstore. However, when i downloaded it to test, it crashes.
08-21 03:48:34.916 926-4059/? I/ActivityManager: START u0
{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
flg=0x10000000 pkg=com.rayzor536.appointments
cmp=com.rayzor536.appointments/.MainActivity} from uid 10039
08-21 03:48:34.995 926-4061/? I/ActivityManager: Start proc 703
4:com.rayzor536.appointments/u0a137 for activity
com.rayzor536.appointments/.MainActivity
08-21 03:48:35.149 7034-7034/? I/zygote: Rejecting re-init on previously-failed class java.lang.Class<com.rayzor536.appointments.MainActivity>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
08-21 03:48:35.149 7034-7034/? I/zygote: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatActivity" on path: DexPathList[[zip file "/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/lib/arm, /system/lib, /system/vendor/lib]]
08-21 03:48:35.152 7034-7034/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.rayzor536.appointments, PID: 7034
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.rayzor536.appointments/com.rayzor536.appointments.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.rayzor536.appointments.MainActivity" on path: DexPathList[[zip file "/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/lib/arm, /system/lib, /system/vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2680)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2857)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1590)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6499)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.rayzor536.appointments.MainActivity" on path: DexPathList[[zip file "/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/lib/arm, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2670)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2857)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1590)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6499)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 12 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatActivity" on path: DexPathList[[zip file "/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/lib/arm, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 15 more
08-21 03:48:35.157 926-5481/? W/ActivityManager: Force finishing activity com.rayzor536.appointments/.MainActivity
08-21 03:48:35.173 926-1066/? I/ActivityManager: Showing crash dialog for package com.rayzor536.appointments u0
08-21 03:48:35.662 926-1065/? W/ActivityManager: Activity pause timeout for ActivityRecord{6e9e3f1 u0 com.rayzor536.appointments/.MainActivity t1469 f}
08-21 03:48:35.895 926-1416/? I/WindowManager: Failed to capture screenshot of Token{26fabd6 ActivityRecord{6e9e3f1 u0 com.rayzor536.appointments/.MainActivity t1469 f}} appWin=Window{313f14f u0 Splash Screen com.rayzor536.appointments EXITING} drawState=4
08-21 03:48:42.402 926-5481/? W/ActivityManager: Force finishing activity com.rayzor536.appointments/.MainActivity
08-21 03:48:42.404 926-5481/? I/ActivityManager: Killing 7034:com.rayzor536.appointments/u0a137 (adj 900): crash
my gradle file is below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.rayzor536.appointments"
minSdkVersion 23
targetSdkVersion 27
versionCode 3
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFile 'proguard-rules.pro'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.android.support:multidex:1.0.3'
}
Here is my app manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rayzor536.appointments">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:name="android.support.multidex.MultiDexApplication">
<activity android:name="com.rayzor536.appointments.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
the error line
Didn't find class "com.rayzor536.appointments.MainActivity"
says that somewhere you have been messed up with the android manifest.xml file
once check if the manifest file is good after changing your version code.
I have a problem, I have it with all my projects, so I came up with a new project with Android 3 Canary 7, but it always gives me the same error.
I have MacOS Sierra 10.12.6
It's a complete new project, so i don't know what to do to solve it
This error occurs:
07-24 10:25:57.776 29708-29708/com.estebanmoncaleano.myapplication
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.estebanmoncaleano.myapplication, PID: 29708
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.estebanmoncaleano.myapplication/com.estebanmoncaleano.myapplication.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.estebanmoncaleano.myapplication.MainActivity" on path:
DexPathList[[zip file
"/data/app/com.estebanmoncaleano.myapplication-2/base.apk", zip file
"/data/app/com.estebanmoncaleano.myapplication-2/split_lib_dependencies_apk.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]]
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2972)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3243)
at android.app.ActivityThread.access$1000(ActivityThread.java:218)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1718)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6917)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.estebanmoncaleano.myapplication.MainActivity" on path:
DexPathList[[zip file
"/data/app/com.estebanmoncaleano.myapplication-2/base.apk", zip file
"/data/app/com.estebanmoncaleano.myapplication-2/split_lib_dependencies_apk.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]]
at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1094)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2962)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3243)
at android.app.ActivityThread.access$1000(ActivityThread.java:218)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1718)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6917)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Suppressed: java.lang.ClassNotFoundException:
com.estebanmoncaleano.myapplication.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the
boot class loader; no stack available
My Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.estebanmoncaleano.myapplication"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
My Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.estebanmoncaleano.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
My Gradle Proyect Settings:
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableAapt2=false
What do you think I can do to solve my problem?
Thanks for your time!
Seems instant run is broken.
Try Stop → Run(not Apply changes - yellow lighting-shape), or Clean → Rebuild.
Clean your project, rebuild and run it. That's working for me. Thanks.
I'm trying to run the javafxports sample project Kokos as I want to use JavaFX components in an app built in Android Studio but can't get it to build properly, I can build all other samples but this mixed approach isn't working.
When I build I just get a black screen and the error "java.lang.ClassNotFoundException: Didn't find class "org.javafxports.kokos.Main" on path: DexPathList[[zip file "/data/app/org.javafxports.kokos-2/base.apk"]"
As far as I can tell, none of the kokos classes are actually built into the apk hence why it can't find them, but I can't work out why and this is the only sample I can find of this approach.
Is anyone able to successfully build and run the Kokos sample and if so, did it require any modification?
Alternatively is there another example of using JavaFX components in an Android project like this that I could use as a basis? I just want to be able to have an app consisting of native Android activities but with the ability to launch into a JavaFX activity.
The error message given is:
02-01 21:43:16.406 17575-17575/org.javafxports.kokos V/DalvikLauncher: Launch JavaFX application on DALVIK vm.
02-01 21:43:16.409 17575-17575/org.javafxports.kokos V/DalvikLauncher: We have JavaFX on our current (base) classpath, registered exit listener
02-01 21:43:16.410 17575-17575/org.javafxports.kokos E/DalvikLauncher: Launch failed with exception.
java.lang.ClassNotFoundException: Didn't find class "org.javafxports.kokos.Main" on path: DexPathList[[zip file "/data/app/org.javafxports.kokos-1/base.apk"],nativeLibraryDirectories=[/data/app/org.javafxports.kokos-1/lib/arm, /data/app/org.javafxports.kokos-1/base.apk!/lib/armeabi, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at javafxports.android.DalvikLauncher.resolveApplicationClass(DalvikLauncher.java:262)
at javafxports.android.DalvikLauncher.launchApp(DalvikLauncher.java:164)
at javafxports.android.FXDalvikEntity.getLauncherAndLaunchApplication(FXDalvikEntity.java:162)
at javafxports.android.FXDalvikEntity.surfaceCreated(FXDalvikEntity.java:304)
at android.view.SurfaceView.updateWindow(SurfaceView.java:583)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:177)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2063)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1115)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6023)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
Suppressed: java.lang.ClassNotFoundException: Didn't find class "org.javafxports.kokos.Main" on path: DexPathList[[dex file "/data/dalvik-cache/xposed_XResourcesSuperClass.dex"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 23 more
Suppressed: java.lang.ClassNotFoundException: org.javafxports.kokos.Main
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 24 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
02-01 21:43:16.411 17575-17575/org.javafxports.kokos V/FXEntity: Called Surface changed [1080, 1848], format 4
02-01 21:43:16.411 17575-17575/org.javafxports.kokos V/FXActivity native: [JVDBG] SURFACE created native android window at 0xa47cd508, surface = 0xff9d0f60
02-01 21:43:16.412 17575-17575/org.javafxports.kokos V/FXEntity: Called Surface redraw needed
02-01 21:43:16.423 17575-17575/org.javafxports.kokos V/FXEntity: Called Surface redraw needed
02-01 21:43:16.441 1378-1536/system_process I/ActivityManager: Displayed org.javafxports.kokos/javafxports.android.FXActivity: +330ms
Here is my app/build.gradle file, I've tried to update the dependencies but still am having issues, is there anything obviously wrong?
My original app/build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.5.0'
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
repositories {
jcenter()
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
// minSdkVersion 16
buildToolsVersion "23.0.2"
dexOptions {
preDexLibraries = false
}
defaultConfig {
applicationId "lodgon.org.kokos"
minSdkVersion 16
targetSdkVersion 16
versionCode 1
versionName "1.0"
multiDexEnabled true
}
sourceSets {
main {
jniLibs.srcDir file("/opt/dalvik-sdk/rt/lib")
assets.srcDirs = ['assets']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile fileTree(include: ['*.jar'], dir: '/opt/dalvik-sdk/rt/lib/ext')
}
project.tasks.withType(com.android.build.gradle.tasks.Dex) {
additionalParameters=['--core-library']
}
My edited app/build.gradle
I applied some suggested fixes, and changed the applicationID and dalvik-sdk location but am still having the same issue, file now looks like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.5.0'
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
repositories {
jcenter()
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
// minSdkVersion 16
buildToolsVersion "23.0.2"
dexOptions {
preDexLibraries = false
}
defaultConfig {
applicationId "javafxports.org.kokos"
minSdkVersion 16
targetSdkVersion 16
versionCode 1
versionName "1.0"
multiDexEnabled true
}
sourceSets {
main {
jniLibs.srcDir file("C:\\Users\\AdamL\\.gradle\\caches\\modules-2\\files-2.1\\org.javafxports\\dalvik-sdk\\8.60.8\\6630ec66e4703c910ac3fd6151a8494c8b59186b\\unpacked\\dalvik-sdk\\rt\\lib")
assets.srcDirs = ['assets']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile fileTree(include: ['*.jar'], dir: 'C:\\Users\\AdamL\\.gradle\\caches\\modules-2\\files-2.1\\org.javafxports\\dalvik-sdk\\8.60.8\\6630ec66e4703c910ac3fd6151a8494c8b59186b\\unpacked\\dalvik-sdk\\rt\\lib\\ext')
}
project.tasks.withType(com.android.build.gradle.tasks.Dex) {
additionalParameters=['--core-library']
}
Android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="javafxports.org.kokos" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="javafxports.org.kokos.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Theseare the changes I've made from the downloaded sample project
JavaFXPorts plugin changed to version 1.32
Changed android-gradle plugin references to version 2.2.3
Changed retrolamba version to 3.5.0
Changed applicationID to correct one
Changed dalvik-sdk location to correct one
The build is being run from the containing samples project like: gradlew :Kokos:androidInstall
There are several problems on your build.gradle file.
The application id is wrong, you should use the package name:
defaultConfig {
applicationId "javafxports.org.kokos"
...
}
The dalvik-sdk path is incorrect. The one you have (/opt/dalvik-sdk) is Linux based.
If you have tried the other JavaFXPorts samples, you will have already downloaded a recent version of the dalvik-sdk, and it will be installed in the .gradle repository.
You will find it under:
C:\Users\<user>\.gradle\caches\modules-2\files-2.1\org.javafxports\dalvik-sdk\8.60.8\<id>\unpacked\dalvik-sdk
Find the right path and replace it in both sourceSets (jniLibs.srcDir) and dependencies.
In case this is helpful to anyone else, I found out what was wrong in my case.
The samples project readme file suggests you should be able to run the project from the root samples project like the other projects using `gradlew :Kokos:androidInstall- or at least it doesn't claim otherwise. This is NOT how I had success running the project.
To run this project, open just the Kokos project and use gradlew installDebug
Additionally I updated my dependencies, Davik SDK location (as Jose Pereda suggested) and changed the way the core-library flag was set in gradle to replace the old way:
dexOptions {
...
additionalParameters=[ '--core-library']
...
}
I am trying to solve a problem with running Android app that has over 65k methods.
I have followed Google docs about Multidex support, however I'm still unable to run it successfully. It seems that the problem appears only on SDK less than 21, because when I specify minSdkVersion 21, it works well, however once I set it to minSdkVersion 15, I am getting following exception.
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate application custom.package.name.MyApplication: java.lang.ClassNotFoundException: Didn't find class "custom.package.name.MyApplication" on path: DexPathList[[zip file "/data/app/custom.package.name-2/base.apk"],nativeLibraryDirectories=[/data/app/custom.package.name-2/lib/arm, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:578)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "custom.package.name.MyApplication" on path: DexPathList[[zip file "/data/app/custom.package.name-2/base.apk"],nativeLibraryDirectories=[/data/app/custom.package.name-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newApplication(Instrumentation.java:981)
at android.app.LoadedApk.makeApplication(LoadedApk.java:573)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suppressed: java.io.IOException: Failed to open dex files from /data/app/custom.package.name-2/base.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:295)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:279)
at dalvik.system.DexPathList.makePathElements(DexPathList.java:248)
at dalvik.system.DexPathList.<init>(DexPathList.java:120)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:65)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:58)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:376)
at android.app.LoadedApk.makeApplication(LoadedApk.java:568)
... 9 more
Suppressed: java.lang.ClassNotFoundException: custom.package.name.MyApplication
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Logcat before fatal exception
W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/custom.package.name-2/base.apk --oat-file=/data/dalvik-cache/arm/data#app#custom.package.name-2-2#base.apk#classes.dex) because non-0 exit status
W/art: Failure to verify dex file '/data/app/ccustom.package.name-2-2/base.apk': Invalid method name: '_clinit#1433781298707#0'
W/System: ClassLoader referenced unknown path: /data/app/custom.package.name-2-2/lib/arm
Here is what I've done so far:
created class called MyApplication that extends Application and specified it in AndroidManifest.xml file
added dependency to build.gradle file
compile 'com.android.support:multidex:1.0.1'
enabled multidex in build.gradle
multiDexEnabled true
enabled multidex in MyApplication class
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Thanks in advance for any help!
Try this, this is working for me, pretty much copied from a current project....
build.gradle
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "my.package.name"
minSdkVersion 16
targetSdkVersion 23
multiDexEnabled = true
versionCode 3
versionName "0.1.2"
renderscriptTargetApi 14
renderscriptSupportModeEnabled true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:multidex:1.0.1'
}
Application Class
public class MyApp extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
}
}
Manifest
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
...
<application
android:name=".MyApp"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
...
It is worth noting that I had a similar issue until i added the READ permission and extends MultiDexApplication
Problem is because of this obfuscator:
<dependency>
<groupId>net.java.truelicense</groupId>
<artifactId>truelicense-obfuscate</artifactId>
<version>${truelicense.obfuscate.version}</version>
</dependency>
This is my error log acheived with android studio 1.0.2
02-03 13:05:23.831 8385-8385/com.******.*******E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.support.v4.app.NavUtilsJB
at android.support.v4.app.NavUtils$NavUtilsImplJB.getParentActivityName(NavUtils .java:125)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:302)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:281)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:142)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at com..******.*******.****.ActivityWelcome.onCreate(ActivityWelcome.java:33)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Configuration
buildToolsVersion "21.1.2"
android SDK TOOLS"24.0.2"
multidex enabled
predexLibraries =false
incremental = true
jumboMode = false
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:support-v4:21.0.3#aar'
compile 'com.android.support:appcompat-v7:21.0.3#aar'
compile project(':ViewPagerIndicator')
compile('de.keyboardsurfer.android.widget:crouton:1.8.4#aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile 'org.java-websocket:Java-WebSocket:1.3.0'
}
How to solve this error?
gradlew clean not helps. Build folders deletion also not working. Android studio shows no errors while compiling.
I had this problem and just found the solution - answer is RTFM! Here are the instructions: https://developer.android.com/tools/building/multidex.html
Multidexing is a new feature and so requires a support library to be compatible with pre-lollipop devices. You need to add the following to your gradle file dependencies:
compile 'com.android.support:multidex:1.0.0'
Also enable multidex output in your gradle file:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
}
And then add the multidex support application to your manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Note: If your app already extends the Application class, you can override the attachBaseContext() method and call MultiDex.install(this) to enable multidex. For more information, see the MultiDexApplication reference documentation.
#Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
MultiDex.install(this);
}
Again, see the instruction above for more information...
Hope this helps
Was stuck for hours due to this issue but finally got the solution.
Step#1:
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Step#2:
defaultConfig {
multiDexEnabled true
}
Step#3:
public class AppController extends Application {
#Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
}
}
Happy coding!
Following solution worked for me:
Add multiDexEnabled = true in your default Config
Add compile com.android.support:multidex:1.0.0 in your dependencies
Application class extend MultiDexApplication instead of just Application
In our case we got this error when we updated "support-v4" lib from 19 to 24 version.
Version 19 contains NavUtilsJB class:
But version 24 does not contain NavUtilsJB class:
Solution for this issue was just to create NavUtilsJB class inside our project:
package android.support.v4.app;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
class NavUtilsJB {
public static Intent getParentActivityIntent(Activity activity) {
return activity.getParentActivityIntent();
}
public static boolean shouldUpRecreateTask(Activity activity, Intent targetIntent) {
return activity.shouldUpRecreateTask(targetIntent);
}
public static void navigateUpTo(Activity activity, Intent upIntent) {
activity.navigateUpTo(upIntent);
}
public static String getParentActivityName(ActivityInfo info) {
return info.parentActivityName;
}
}