在项目中,我有几个风格,几个构建类型和几个文件夹
构建组合:
文件夹结构
在每个文件夹中,我都有自定义的Application class
AndroidManifest
来注册这个Application class
有时,但只是有时生成失败,出现“找不到符号”错误:
\app\src\main\java\ru\my\package\app\environment\MyApp.java:35: error: cannot find symbol
.core(new CrashlyticsCore.Builder().disabled(!BuildConfig.ANALYTICS).build())
或与类无关但错误相同
\app\src\main\java\ru\my\package\presentation\presenter\impl\MainPresenterImpl.java:104: error: cannot find symbol
if (!BuildConfig.ANALYTICS) return;
但是下一个构建可能会成功,所以可能的流程是
注意事项
免责声明:有些问题看起来像这一个,但它们是不同的,例如。
Gradle buildConfigField BuildConfig无法解析符号
更新
渐变依赖项:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(path: ':OVSALibrary')
implementation project(path: ':YaMapProject')
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.google.dagger:dagger:2.14.1'
kapt 'com.google.dagger:dagger-compiler:2.14.1'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'eu.davidea:flexible-adapter:5.0.0-rc3'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
implementation "com.android.support:appcompat-v7:$support_lib_version"
implementation "com.android.support:design:$support_lib_version"
implementation "com.android.support:support-v4:$support_lib_version"
implementation "com.android.support:recyclerview-v7:$support_lib_version"
implementation "com.android.support:support-emoji:$support_lib_version"
implementation "com.android.support:support-emoji-appcompat:$support_lib_version"
implementation "com.android.support:support-emoji-bundled:$support_lib_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.7'
implementation 'ru.egslava:MaskedEditText:1.0.5'
implementation 'nl.big-o:liqp:0.7.3'
implementation 'org.jsoup:jsoup:1.7.2'
implementation 'me.everything:overscroll-decor-android:1.0.4'
implementation 'com.squareup.picasso:picasso:2.6.0-SNAPSHOT'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
compile ('com.squareup.retrofit2:converter-simplexml:2.3.0') {
exclude group: 'stax', module: 'stax-api'
exclude group: 'stax', module: 'stax'
exclude group: 'xpp3', module: 'xpp3'
}
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation ('com.github.revern:socket.io-client-java:master-SNAPSHOT') {
exclude group: 'org.json', module: 'json'
}
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'
implementation 'com.luckycatlabs:SunriseSunsetCalculator:1.2'
implementation ('com.github.developer-shivam:Crescento:1.2.1') {
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'palette-v7'
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
transitive = true;
}
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.malinskiy:superrecyclerview:1.1.4'
// Yandex.Map things
implementation 'com.yandex.android:mapkit:3.0.0'
// Yandex ads. Adfox.
rcImplementation 'com.yandex.android:mobmetricalib:3.0.0'
debugWithAnalyticsImplementation 'com.yandex.android:mobmetricalib:3.0.0'
releaseImplementation 'com.yandex.android:mobmetricalib:3.0.0'
implementation 'com.yandex.android:mobileads:2.71'
// Waiting for https://github.com/SundeepK/CompactCalendarView/pull/287
// Waiting for https://github.com/SundeepK/CompactCalendarView/pull/288
implementation 'com.github.dryaz:CompactCalendarView:master-SNAPSHOT'
// Waiting for https://github.com/opacapp/multiline-collapsingtoolbar/pull/57
implementation 'com.github.dryaz:multiline-collapsingtoolbar:master-SNAPSHOT'
implementation 'com.github.clans:fab:1.6.4'
implementation 'org.greenrobot:eventbus:3.1.1'
testImplementation "org.robolectric:robolectric:3.8"
testImplementation 'junit:junit:4.12'
testImplementation "com.android.support.test:monitor:1.0.2"
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// PAY SDK
implementation(name:'mos-pay-sdk-1.0.9', ext:'aar')
implementation 'io.card:android-sdk:5.5.1'
implementation ('eu.livotov.labs.android:3DSView:1.1.2@aar') {transitive=true}
// Android Architecture Components
implementation "android.arch.lifecycle:runtime:$androidArch"
implementation "android.arch.lifecycle:extensions:$androidArch"
annotationProcessor "android.arch.lifecycle:compiler:$androidArch"
compile 'com.google.firebase:firebase-core:16.0.0'
compile 'com.google.firebase:firebase-messaging:17.0.0'
}
**更新**这是构建类型和产品风格的列表
flavorDimensions("devbeta", "mainmirror")
productFlavors {
// Beta API enviroment
beta {
dimension = "devbeta"
buildConfigField "String", "SOCKET_REMOTE_PATH", "\"/api-beta/socket.io\""
}
// Dev API enviroment
dev {
dimension = "devbeta"
buildConfigField "String", "SOCKET_REMOTE_PATH", "\"/api-dev/socket.io\""
}
// Prod API enviroment
prod {
dimension = "devbeta"
buildConfigField "String", "SOCKET_REMOTE_PATH", "\"/socket.io\""
}
mainhost {
dimension = "mainmirror"
buildConfigField "String", "CONFIG_REMOTE_HOSTNAME", "\"some.host.url\""
}
mirrorhost {
dimension = "mainmirror"
buildConfigField "String", "CONFIG_REMOTE_HOSTNAME", "\"some.host.url\""
}
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
buildConfigField "boolean", "ANALYTICS", "false"
signingConfig signingConfigs.customDebug
ext.enableCrashlytics = false
manifestPlaceholders = [
firebaseAnalyticsDeactivated: "true",
appIcon: "@mipmap/ic_launcher_debug",
]
}
debugWithAnalytics.initWith(buildTypes.debug)
debugWithAnalytics {
ext.betaDistributionGroupAliases = "group-internal"
ext.betaDistributionReleaseNotes = "$getReleaseNotes"
ext.enableCrashlytics = true
buildConfigField "boolean", "ANALYTICS", "true"
matchingFallbacks = ['debug', 'release']
}
debugWithProguard.initWith(buildTypes.debug)
debugWithProguard {
minifyEnabled true
shrinkResources true
proguardFiles(file('./proguard').listFiles())
matchingFallbacks = ['release', 'debug']
}
// RC build for inner testers that has analytics, signed with debug key.
rc {
minifyEnabled true
shrinkResources true
proguardFiles(file('./proguard').listFiles())
buildConfigField "boolean", "ANALYTICS", "true"
// Fields for fabric beta distribution
ext.betaDistributionGroupAliases = "group-internal"
ext.betaDistributionReleaseNotes = "$getReleaseNotes"
signingConfig signingConfigs.customDebug
manifestPlaceholders = [
firebaseAnalyticsDeactivated: "false",
appIcon: "@mipmap/ic_launcher_rc",
]
matchingFallbacks = ['debug', 'release']
}
release.initWith(buildTypes.rc)
release {
buildConfigField "boolean", "ANALYTICS", "true"
ext.betaDistributionGroupAliases = "group-customer"
signingConfig signingConfigs.release
manifestPlaceholders = [
firebaseAnalyticsDeactivated: "false",
appIcon: "@mipmap/ic_launcher",
]
}
}
最后看起来我找到了一个原因,我的库项目与主应用程序的包ID完全相同,因此库项目的内部BuildConfig不包含变量。
这可能完全是胡说八道,但您是否曾经在defaultConfig中直接放置默认值来测试过它?
defaultConfig {
buildConfigField "boolean", "ANALYTICS", "false"
}
如果在导入包名时仍然存在问题,请重新生成项目,然后。构建配置
我正在用Android Studio制作我的第一个测试程序。 该程序有两个活动,您在第一个活动中插入一个文本,按下一个按钮,然后文本在另一个活动上显示。 我下面的YT教程,但我发现两个错误: 找不到符号变量,也找不到解决方案。 我在这里搜索了这么久,但没有找到有效的答案。我试过: > 清洁项目和重建项目。 我没有"导入Android。R". 我用了但它告诉我"未使用的导入语句"。 我已经更改了ID
我遇到了一个奇怪的问题!我的xml文件中有每个布局的id名,并且在我的主要活动中创建了对它们的变量引用。java文件。 当我清理和重建我的项目时,我得到的是: “错误:找不到符号layoutMain=findViewById(r.id.layoutMain);” 我在用敏。SDK 21,目标29
嗨,我试着把谷歌分析在我的应用程序,我看到留档,但不为我工作,我有这个错误错误:(51,9)错误:找不到符号变量mTracker: 分析pplication.java 显示: 主要活动 ... 错误:错误:(51,9)错误:找不到符号变量mTracker 修复:问题是我需要将其放入主活动: 公共类主活动扩展活动{
错误是: 找不到符号
我是新人。每当我试图构建并运行这段代码时,都会出现这条消息。 下面是 XML 代码: 下面是Java代码: /***重要事项:在下面添加您的包裹。包名称可以在项目的AndroidManifest中找到。xml文件。*这是我们的示例使用的包名称:**packagecom.example.android。justjava;**/ 导入Android。R;导入Android捆绑包;import andr
这里有一个类似的答案:如何在Java中将函数作为参数传递? 但提供的正确答案不起作用。我有一门课: 在函数内部我试图将传递到,但我得到的错误是: 找不到符号 符号:类Callable 我不知道为什么。 另外,我尝试使用返回类型字符串作为xMethod,您能传递一个返回类型不同的函数吗?