-5

I'm working on telegram source code. All things is right and now app will install and run successfully on devices.

But in devices with android version 4.0.1 up to android version 4.2.2 the app will stop with the error shown below. I changed the defaultConfig.applicationId in build.gradle to ir.familygram.messenger and guess this is the problem , but why it work good on devices with sdk 22,23 ,etc. and not work in devices with lower android sdk?

the error in android device monitor:

01-09 15:45:40.190: E/AndroidRuntime(8158): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{ir.familygram.messenger/org.telegram.ui.LaunchActivity}: java.lang.ClassNotFoundException: org.telegram.ui.LaunchActivity
01-09 15:45:40.190: E/AndroidRuntime(8158):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1998)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2099)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at android.app.ActivityThread.access$600(ActivityThread.java:138)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at android.os.Looper.loop(Looper.java:137)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at android.app.ActivityThread.main(ActivityThread.java:4954)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at java.lang.reflect.Method.invokeNative(Native Method)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at java.lang.reflect.Method.invoke(Method.java:511)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:798)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at dalvik.system.NativeStart.main(Native Method)
01-09 15:45:40.190: E/AndroidRuntime(8158): Caused by: java.lang.ClassNotFoundException: org.telegram.ui.LaunchActivity
01-09 15:45:40.190: E/AndroidRuntime(8158):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at android.app.Instrumentation.newActivity(Instrumentation.java:1056)
01-09 15:45:40.190: E/AndroidRuntime(8158):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1989)
01-09 15:45:40.190: E/AndroidRuntime(8158):     ... 11 more
01-09 15:58:00.770: E/Trace(9057): error opening trace file: No such file or directory (2)
MalaKa
  • 3,734
  • 2
  • 18
  • 31
Hosein Kord
  • 187
  • 2
  • 15

1 Answers1

0

Answer link : NoClassDefFoundError below SDK 21

I resolved the issue by adding this to my Application Class.

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

If you don't have/use Application class, you can put this:

 android:name="android.support.multidex.MultiDexApplication"

Into your tag on AndroidManifest.xml

If you already have implemented an Application class

Also obviously, you need to add the Gradle dependency:

compile 'com.android.support:multidex:1.0.0'

More info about 65k methods problem: https://developer.android.com/tools/building/multidex.html

Community
  • 1
  • 1
Hosein Kord
  • 187
  • 2
  • 15