androidbuildpackageandroid-manifestandroid-variants

"is package not installed?" exception for project have different build variants


I have a question. When project is run, I rarely get fatal exception. I have two different android applications in the same project for different build variants. But their package name are different. In manifest file, my first application's package name is written. I rarely get fatal exception, when I run my second project.

How can I fix this error?

06-15 10:58:19.104 2322-2322/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process:  com.xxx.yyy.zzz, PID: 2322
                                                 java.lang.RuntimeException:Unable to instantiate application android.app.Application: java.lang.IllegalStateException: Unable to get package info for >com.xxx.yyy.zzz; is package not installed?
                                                     at android.app.LoadedApk.makeApplication(LoadedApk.java:563)
                                                     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4526)
                                                     at android.app.ActivityThread.access$1500(ActivityThread.java:151)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                     at android.os.Looper.loop(Looper.java:135)
                                                     at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                     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:903)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                  Caused by: java.lang.IllegalStateException: Unable to get package info for com.xxx.yyy.zzz; is package not installed?
                                                     at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:409)
                                                     at android.app.LoadedApk.makeApplication(LoadedApk.java:555)
                                                     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4526) 
                                                     at android.app.ActivityThread.access$1500(ActivityThread.java:151) 
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                     at android.os.Looper.loop(Looper.java:135) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                     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:903) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 

Solution

  • You should control your architecture, does anywhere else control your build variants or have your project any xml file regarding build-variants as static string.