几天来我一直在修改代码,但我无法让Gradle为我组装一个已签名的APK(遵循错误代码说明将导致构建成功,但我的Google Calendar API失败)。 / p>
dependencies {
// commented stuff is no longer used or commented for some other reason.
//compile 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
// Dont know whats up with these errors above. ^
// they seem to work even though they are "incompatible"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.code.findbugs:jsr305:3.0.1'
implementation('com.google.api-client:google-api-client-android:1.23.0') {
exclude module: 'guava-jdk5'
//exclude group: 'org.apache.httpcomponents'
}
implementation 'com.android.support:multidex:1.0.3'
//implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.android.support:cardview-v7:28.0.0'
//implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.bartoszlipinski.constraint:staggeredanimationgroup:1.0.0'
implementation 'com.android.support:transition:28.0.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.firebase:firebase-messaging:17.3.2'
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.1'
implementation 'com.google.firebase:firebase-core:16.0.3'
/*Make sure these are always updated to the newest versions.*/
implementation('com.google.oauth-client:google-oauth-client-jetty:1.23.0') {
exclude module: 'guava-jdk5'
}
implementation('com.google.apis:google-api-services-calendar:v3-rev305-1.23.0') {
exclude module: 'guava-jdk5'
}
//implementation 'pub.devrel:easypermissions:0.3.0'
implementation 'com.google.http-client:google-http-client-jackson:1.15.0-rc'
//implementation 'com.google.android.gms:play-services-auth:16.0.0'
这些是我对Gradle文件的依赖。
忽略“ com.android.support:support-vector-drawable:28.0.0”上的错误,因为它很好;我只是无法让我的APK组装成签名;并且在强制执行时,我的Google日历代码不会返回事件。
Executing tasks: [:app:assembleRelease]
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
:app:checkReleaseClasspath
:app:preBuild UP-TO-DATE
:app:preReleaseBuild
:app:compileReleaseAidl NO-SOURCE
:app:compileReleaseRenderscript UP-TO-DATE
:app:checkReleaseManifest UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:mainApkListPersistenceRelease UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:processReleaseGoogleServices
Parsing json file: C:\Users\Dylan\Documents\ClarenceFultonSecondary\app\google-services.json
:app:mergeReleaseResources
:app:createReleaseCompatibleScreenManifests UP-TO-DATE
:app:processReleaseManifest
:app:splitsDiscoveryTaskRelease UP-TO-DATE
:app:processReleaseResources
:app:generateReleaseSources
:app:javaPreCompileRelease
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileReleaseJavaWithJavac
:app:compileReleaseNdk NO-SOURCE
:app:compileReleaseSources
C:\Users\Dylan\Documents\ClarenceFultonSecondary\app\build.gradle: Error: commons-logging defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]
C:\Users\Dylan\Documents\ClarenceFultonSecondary\app\build.gradle: Error: httpclient defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]
Explanation for issues of type "DuplicatePlatformClasses":
There are a number of libraries that duplicate not just functionality of
the Android platform but using the exact same class names as the ones
provided in Android -- for example the apache http classes. This can lead
to unexpected crashes.
To solve this, you need to either find a newer version of the library which
no longer has this problem, or to repackage the library (and all of its
dependencies) using something like the jarjar tool, or finally, rewriting
the code to use different APIs (for example, for http code, consider using
HttpUrlConnection or a library like okhttp).
2 errors, 0 warnings
:app:lintVitalRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
Lint found fatal errors while assembling a release target. To proceed, either fix the issues identified by lint, or modify your build script as follows: ... android { lintOptions { checkReleaseBuilds false // Or, if you prefer, you can continue to check for errors in release builds, // but continue the build even when errors are found: abortOnError false } } ... * 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. * Get more help at https://help.gradle.org BUILD FAILED in 31s
这是我的皮棉报告所说的:
重复的平台类
../../ build.gradle:commons-logging定义了与Android现在提供的类冲突的类。解决方案包括查找没有相同问题的较新版本或替代库(例如,对于httpclient使用HttpUrlConnection或okhttp替代),或使用jarjar之类的库重新打包该库。
../../ build.gradle:httpclient定义与Android现在提供的类冲突的类。解决方案包括查找没有相同问题的较新版本或替代库(例如,对于httpclient使用HttpUrlConnection或okhttp替代),或使用jarjar之类的库重新打包该库。
答案 0 :(得分:0)
在app / build.gradle中添加以下代码。
configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}