我有一个现有的 Android 应用程序,我正在将其迁移到 Marshmallow。当我通过 build.gradle 和 dependancies 更改为 support:appcompat-v7 时,我开始意识到一个奇怪的问题。我的扩展 AppCompatActivity 的 Activity 类显示错误。
这是我的build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
debug{
buildConfigField "String", "ANDROIDPAY_PUBLIC", "\"""
buildConfigField "String", "ANDROIDPAY_PRIVATE", """
}
release {
buildConfigField "String", "ANDROIDPAY_PUBLIC", " "String", "ANDROIDPAY_PRIVATE", "\"""
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
publishNonDefault true //for maintaining product flavor
productFlavors {
{
}
{
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
compile 'com.google.android.gms:play-services-wallet:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-appstate:8.4.0'
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.guava:guava:18.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile files('libs/GoogleConversionTrackingSdk-2.2.2.jar')
compile files('libs/AF-Android-SDK-v3.3.0.jar')
compile files('libs/crittercism_v5_3_3_sdkonly.jar')
compile files('libs/Kahuna.jar')
compile('com.optimizely:optimizely:1.4.2@aar') {
transitive = true
exclude group: 'com.google.code.gson', module: 'gson'
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
compile 'io.card:android-sdk:5.3.0'
compile 'io.jsonwebtoken:jjwt:0.6.0'
compile "com.squareup.okhttp3:okhttp:3.0.1"
compile files('libs/commons-codec-1.10.jar')
compile files('libs/bcprov-jdk15on-154.jar')
/*compile 'com.paypal.sdk:paypal-android-sdk:2.13.3'*/
compile 'net.hockeyapp.android:HockeySDK:4.1.0-beta.1'
compile files('libs/devicecollector-sdk-2.6.jar')
}
在 Activity 中我正在使用这段代码
public abstract class BaseController extends AppCompatActivity{
....
}
我遇到的错误是无法解析符号“AppCompatActivity”
当我使用时一切正常 编译 'com.android.support:appcompat-v7:22.4.0'。使用 23.+ 版本时出现问题。
最佳答案
解决了。问题出在 Android Studio 上。我必须使缓存无效并重新启动 Android Studio,然后问题就解决了。
关于java - 无法解析 v7 :23. + 的 AppCompatActivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37525709/