1

I'm currently working on Android instant apps by using the android-topeka example project.

Everything works as expected, after I'm using AndroidAnnotations on my Activity:

@EActivity(resName = "activity_start")
public class StartActivity extends AppCompatActivity {
...
}

If I want to start the application(:installed) one, everything works, but for the instant-app(:instant), I get the following error:

:base:javaPreCompileDebugFeature UP-TO-DATE
error: The generated <applicationId>.R class cannot be found
1 error
:base:compileDebugFeatureJavaWithJavac FAILED

Additional Info:

If I remove the application project(':installed') in the base build.gradle I can start the instant-app but with the wrong application-id (configured in the :installed project).

Manuel Schmitzberger
  • 5,162
  • 3
  • 36
  • 45
  • I tinkered with AA and instant apps and got it to work (though, with only the base-feature), saw your post too @ https://github.com/androidannotations/androidannotations/issues/2017. I actually ran into the `Could not find the AndroidManifest.xml` error, not yours, but after I fixed that, it worked. Would you share what your gradle looks like? – TWL Oct 25 '18 at 19:37
  • fyi, `"org.androidannotations:androidannotations-api:4.5.2"` and i added the `library` and `androidManifestFile` arguments (https://github.com/androidannotations/androidannotations/wiki/CustomizeAnnotationProcessing) – TWL Oct 25 '18 at 20:15
  • @TWL thx. now it works. – Manuel Schmitzberger Oct 29 '18 at 06:58

2 Answers2

1

Finally I got it, by the help of this issue tracker (thx to Kay-Uwe Janssen). Also thx to jess. Overall it was the setup combined with the Manifest Finder and the annotationProcessorOptions.

This is how my gradle/Manifest setup looks like:

Base:

build.gradle:

android {
    ...

    baseFeature true

    defaultConfig {
        ...

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["resourcePackageName": "com.test.base"]
            }
        }
    }

    buildTypes {
        release {
        }
    }
}
dependencies {
    application project(':installed')
    ...
}

AndroidManifest.xml:

<manifest ...
    package="com.test.base">
    ...
</manifest>

Installed:

build.gradle:

android {
      ...
}

dependencies {
    implementation project(':base')
}

AndroidManifest.xml:

<manifest package="com.test2">
</manifest>

Instant:

build.gradle:

android {
    defaultConfig {}
}

dependencies {
    implementation project(':base')
}

With this setup, the Instant App has the same App-Id as the Installed one "com.test2"

Manuel Schmitzberger
  • 5,162
  • 3
  • 36
  • 45
  • Please update to AndroidAnnotations 4.6.0, which has Instant app support. I believe less configuration is necessary now. – WonderCsabo Feb 15 '19 at 19:45
0

Based from this SO related post:

This error happens when you modify the applicationId. The script provided in example assumes that you have declared android.defaultConfig.applicationId. If this was not declared, the value will be null or it generates null.R.

defaultConfig {

    // Rest of Config

    javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["resourcePackageName": "<Original Package Name>"]
            }
    }
}

Note: Original Package Name should be same as the location of R in you activity.

Jessica Rodriguez
  • 2,899
  • 1
  • 12
  • 27