0

So, I had a working app and decided to create 2 build variants. One Debug and one Release build for their respectful logging using Timber. I abstracted out my Application class and provided 2 concrete implementations within the 2 new build variant source sets.

Apparently, this was enough to create this error message. The source sets seem to be good, and I can switch between the two using Android Studio's Build Variant controls.

So, have a overlooked something? Is this a common error message that people get while creating multiple build variants? Just to be clear, this error message is occuring on my only Activity during its onCreate() execution.

  java.lang.RuntimeException: Unable to start activity ComponentInfo{io.github.ciscorucinski.personal.intro/io.github.ciscorucinski.personal.intro.ui.MainActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f0e0076 (io.github.ciscorucinski.personal.intro:id/fragment_container) for fragment IntroductionFragment{bdba6e7 #0 id=0x7f0e0076}
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
      at android.app.ActivityThread.-wrap11(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
      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.IllegalArgumentException: No view found for id 0x7f0e0076 (io.github.ciscorucinski.personal.intro:id/fragment_container) for fragment IntroductionFragment{bdba6e7 #0 id=0x7f0e0076}
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1059)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
      at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
      at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
      at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:339)
      at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:602)
      at io.github.ciscorucinski.personal.intro.ui.MainActivity.onStart(MainActivity.java:281)
      at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
      at android.app.Activity.performStart(Activity.java:6253)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
      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) 

Build.gradle

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {  //applicationIdSuffix ".debug"     
    }
}
sourceSets {
    debug { java.srcDirs = ['src/debug/java', 'src/debug/java/'] }
    release { java.srcDirs = ['src/release/java', 'src/release/java/'] }
}
Christopher Rucinski
  • 4,737
  • 2
  • 27
  • 58
  • First of all, you already by default has two default build configuration **debug** and **release**. So you don't need to do any extra changes in your `build.gradle`. You probably also don't need to do any code separation and just use `BuildConfig.DEBUG` constant. For you error, looks like you moved some resources to one flavour and they are not available in the another – Eugen Martynov May 23 '16 at 06:49
  • Well, yes are are right that those 2 variants are available from the start; however there are changes that need to be made. Mostly the source sets need to be declared? But it turns out Android Studio does that for you. Also, I have chosen the complete code separation method and did not want to use the BuildConfig.DEBUG constant. Lastly, all I have in my Debug sourceset is my concrete implementation of the Application class; nothing else. All I have in my Release sourceset is my concrete implementation of the Application class, and the ReleaseTree logging class. I don't have other resources – Christopher Rucinski May 23 '16 at 09:14
  • In this case do you have already multidex enabled? – Eugen Martynov May 23 '16 at 13:18
  • I also prefer having separate classes instead of using debug flag if it is critical for security or privacy – Eugen Martynov May 23 '16 at 13:19
  • You also don't need to declare any source set. Just move related files into `src/debug` folder – Eugen Martynov May 23 '16 at 13:20
  • I moved back to a single class with the BuildConfig.DEBUG flag but I am still getting this error message. Also, I have not done anything with multidex support – Christopher Rucinski May 23 '16 at 13:21
  • Do you have `fragment_container` on IntroductionFragment? – Eugen Martynov May 23 '16 at 14:18
  • Yes, in OnCreateView I inflate from a layout resource that contains `fragment_container` – Christopher Rucinski May 23 '16 at 15:30

0 Answers0