【问题标题】:AndroidAnnotations + Instant App - The generated <applicationId>.R class cannot be foundAndroidAnnotations + Instant App - 找不到生成的 <applicationId>.R 类
【发布时间】:2018-10-24 15:23:19
【问题描述】:

我目前正在使用 android-topeka 示例项目开发 Android 即时应用程序。

在我的 Activity 上使用 AndroidAnnotations 之后,一切都按预期工作:

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

如果我想启动 应用程序(:installed) 之一,一切正常,但对于 instant-app(:instant),我得到以下错误:

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

其他信息:

如果我删除基础中的application project(':installed') build.gradle 我可以启动 instant-app 但错误 application-id(在:installed 项目中配置)。

【问题讨论】:

标签: android android-annotations android-instant-apps


【解决方案1】:

issue 追踪器的帮助下,我终于明白了(感谢 Kay-Uwe Janssen)。也感谢杰斯。总的来说,它是结合了 Manifest Finder 和 annotationProcessorOptions 的设置。

这是我的 gradle/Manifest 设置的样子:

基地:

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>

已安装:

build.gradle:

android {
      ...
}

dependencies {
    implementation project(':base')
}

AndroidManifest.xml:

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

即时:

build.gradle:

android {
    defaultConfig {}
}

dependencies {
    implementation project(':base')
}

通过此设置,Instant App 与已安装的“com.test2”具有相同的 App-Id

【讨论】:

  • 请更新到支持即时应用的 AndroidAnnotations 4.6.0。我相信现在需要更少的配置。
【解决方案2】:

基于此SO related post:

当您修改applicationId 时会发生此错误。示例中提供的脚本假定您已声明 android.defaultConfig.applicationId。如果未声明,则值为 null 或生成 null.R

defaultConfig {

    // Rest of Config

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

注意:原始Package Name应与您活动中R的位置相同。

【讨论】:

  • 很遗憾,这不适用于 Instant App 设置。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-18
  • 1970-01-01
  • 2022-01-14
相关资源
最近更新 更多