我正在处理一个旧的android项目。如果没有描述api,它可以正常工作。当我尝试实现新的api时,这会造成问题。我没有迁移到android-x
,因为这会给每个文件造成问题。因此,我尝试使用新的sdk而不迁移到android-x
,这是我在implement
的新地方sdk上遇到的另一个问题依赖项版本更改,例如appcompat
等。要坚持使用旧版本,我正在使用resolutionStrategy.force
方法。以下是我当前的Gradle
文件,它当前显示错误class file for com.google.android.gms.common.internal.safeparcel.zza not found
,我该如何解决此问题
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.myapo"
minSdkVersion 16
targetSdkVersion 25
versionCode 27
versionName "1.5"
manifestPlaceholders = [HOCKEYAPP_APP_ID: "51a9c4471559421b8d53a07cbb3e3fa0"]
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
lintOptions { checkReleaseBuilds false }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
//incremental true
}
repositories {
jcenter()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
useLibrary 'org.apache.http.legacy'
}
allprojects {
repositories {
google()
}
repositories {
maven {
url 'https://maven.google.com'
}
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// for PayPal
implementation 'com.android.support:appcompat-v7:25.0.3'
implementation 'com.android.support:design:25.1.0'
implementation 'com.google.maps.android:android-maps-utils:0.4'
implementation 'com.google.android.gms:play-services:10.0.0'//10.0.0
implementation 'com.google.android.gms:play-services-places:10.0.0'//new included
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.hbb20:ccp:1.7.2'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'net.hockeyapp.android:HockeySDK:4.1.3'
implementation 'com.android.support:recyclerview-v7:25.1.1'
implementation 'com.android.support:cardview-v7:25.1.1'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.facebook.android:facebook-android-sdk:4.0.0'
implementation 'com.google.firebase:firebase-messaging:9.6.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.github.krtkush:LinearTimer:v2.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.iarcuschin:simpleratingbar:0.1.5'
implementation 'com.paypal.sdk:paypal-android-sdk:2.15.3'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.libraries.places:places:1.0.0'
}
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:2.0.1'
resolutionStrategy.force 'com.google.android.gms:play-services-clearcut:10.0.1'
resolutionStrategy.force 'com.android.support:appcompat-v7:25.1.1'
resolutionStrategy.force 'com.android.support:recyclerview-v7:25.1.1'
resolutionStrategy.force 'com.android.support:cardview-v7:25.1.1'
resolutionStrategy.force 'com.android.volley:volley:1.0.0'
resolutionStrategy.force 'com.google.code.gson:gson:2.7'
//resolutionStrategy.force 'com.github.bumptech.glide:glide:3.6.1'
resolutionStrategy.force 'com.android.support:support-v4:25.1.1'
resolutionStrategy.force 'com.android.support:recyclerview-v7:25.1.1'
resolutionStrategy.force 'com.android.support:support-fragment:25.1.1'
resolutionStrategy.force 'com.android.support:support-core-ui:25.1.1'
resolutionStrategy.force 'com.android.support:animated-vector-drawable:25.1.1'
resolutionStrategy.force 'com.android.support:support-vector-drawable:25.1.1'
resolutionStrategy.force 'com.android.support:support-media-compat:25.1.1'
resolutionStrategy.force 'com.android.support:support-core-utils:25.1.1'
resolutionStrategy.force 'com.android.support:support-compat:25.1.1'
resolutionStrategy.force 'com.android.support:support-annotations:25.1.1'
resolutionStrategy.force 'com.android.support:appcompat-v7:25.1.1'
}
}
apply plugin: 'com.google.gms.google-services'
下面是我的错误日志
D:\AndroidProject\my_android\app\src\main\java\
com\example\myapo\pushnotification\MyFirebaseMessaging
Service.java:54: error: cannot access zza
Log.e(TAG, "From: " + remoteMessage.getFrom());
^
class file for com.google.android.gms.common.internal.safeparcel.zza not found
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.