相关疑难解决方法(0)

使用gradle查找依赖树

是否有可能使用gradle来生成依赖于什么的树?

我有一个项目,并希望找出所有的依赖项,所以我可以通过前向声明等来修剪它.

gradle

474
推荐指数
15
解决办法
36万
查看次数

如何解决"在APK META-INF/*中复制的重复文件"

我在一个商业Android应用程序工作.我还使用了一些在不同许可证类型下获得许可的库,其中一些库说明了以下内容:

如果图书馆有一份带有归属说明的"NOTICE"文件,则您必须在分发时包含该通知

(其中一个是根据Apache License 2.0获得许可的).

有不止一个图书馆.当我使用gradleAndroid Studio进行构建时,我获得以下构建错误:

* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/license.txt
Run Code Online (Sandbox Code Playgroud)

我在互联网和stackoverflow上找到的答案建议从包装中删除license.txt(notice.txt或其他可能会干扰的文件),方法是添加build.gradle以下文件:

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}
Run Code Online (Sandbox Code Playgroud)

请参阅示例:Android Studio 0.4在APK META-INF/LICENSE.txt中复制的重复文件

根据这些库的许可证(例如Apache License 2.0),应包含许可证和通知文件.

我的问题: 如何将与许可相关的多个文件(例如license.txt,notice.txt等)从gradle添加到我的项目中以符合许可(技术细节:许可文本将被连接)?

java android gradle

91
推荐指数
2
解决办法
6万
查看次数

Retrofit2 + RxJava2 + RxAndroid错误

我在尝试打包Subscriber和订阅时收到如下错误消息.

can not resolve method 'subscribe(anonymous rx.Subscriber<GooglePlacesResponse>)'
Run Code Online (Sandbox Code Playgroud)

的build.gradle

// JSON Parsing
compile 'com.google.code.gson:gson:2.6.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.2'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1
Run Code Online (Sandbox Code Playgroud)

GooglePlaceService.java

public interface GooglePlaceService {

    public static final String GOOGLE_API_KEY = "google_api_key";

    @GET("maps/api/place/nearbysearch/json?radius=2000&key="+GOOGLE_API_KEY)
    Observable<GooglePlacesResponse> getNearbyPlaces(@Query("location") String location);
}
Run Code Online (Sandbox Code Playgroud)

ApiUtils.java

public class ApiUtils {    

    public static final String GOOGLE_PLACE_BASE_URL = "https://maps.googleapis.com/";

    public static GooglePlaceService getGooglePlaceService() {
        return getClient(GOOGLE_PLACE_BASE_URL).create(GooglePlaceService.class);
    }

    public static Retrofit getClient(String baseUrl) {

        Retrofit retrofit = new Retrofit.Builder()
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl(baseUrl)
                .build();

        return retrofit; …
Run Code Online (Sandbox Code Playgroud)

java android rx-android retrofit2 rx-java2

8
推荐指数
2
解决办法
7462
查看次数

解决意想不到的顶级异常的最佳方法是什么?

当我使应用程序使用许多库.我通常遇到一个错误UNEXPECTED TOP-LEVEL EXCEPTION

此错误有一些原因:

  • 数字函数> 65k,我们需要为它启用multidex
  • 有些lib是嵌套的,我们需要在build.gradle中添加exclude.

关于第二种情况,很难检测出嵌套的lib是什么.

如果您对此问题有经验,请与我分享.

更新:

dependencies {
    compile files('libs/ormlite-android-4.48.jar')
    compile files('libs/ormlite-core-4.48.jar')
    //    compile 'com.obsez.android.lib.filechooser:filechooser:1.1.2'
    //    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'cn.lightsky.infiniteindicator:library:1.0.5'
    compile 'com.firebase:firebase-client-android:2.3.1'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.mcxiaoke.volley:library:1.0.15'
    compile('com.google.apis:google-api-services-drive:v2-rev170-1.20.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile('com.google.api-client:google-api-client-android:1.20.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile('com.google.android.gms:play-services:8.4.0') {
        exclude group: 'com.android.support', module: 'support-v4'
    }
    compile 'com.nononsenseapps:filepicker:2.4.1'
}
Run Code Online (Sandbox Code Playgroud)

android exception build.gradle

5
推荐指数
1
解决办法
329
查看次数

Android Studio 1.5.1在APK META-INF/NOTICE.txt中复制的重复文件commons-codec-1.9.jar ...?

commons-codec-1.9.jar ...在APK META-INF/NOTICE.txt中复制的重复文件

> Error:Execution failed for task
> ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files
> copied in APK META-INF/NOTICE.txt     File1:
> C:\Users\nandkishor.mewara\AndroidStudioProjects\New folder
> (2)\CityRetails\app\libs\commons-logging-1.2.jar  File2:
> C:\Users\nandkishor.mewara\AndroidStudioProjects\New folder
> (2)\CityRetails\app\libs\commons-codec-1.9.jar
Run Code Online (Sandbox Code Playgroud)

java apache android

4
推荐指数
1
解决办法
2016
查看次数

从RxAndroid 1.x迁移到2.x(包括RxJava)

我有一个运行RxAndroid 1.x的项目(Everythings works).我正在尝试迁移到2.x版本.

我的gradle文件:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    //compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }

    //compile 'io.reactivex:rxandroid:1.2.1'
    //compile 'io.reactivex:rxjava:1.2.1'
    compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
    compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.4.0'

    compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    compile 'io.reactivex.rxjava2:rxjava:2.0.0'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.0-RC1'
}
Run Code Online (Sandbox Code Playgroud)

我有这个错误:

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties
    File1: /Users/agustin/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxjava/2.0.0/5151c737c01616c372c3d00ab145868ede10e826/rxjava-2.0.0.jar
    File2: /Users/agustin/.gradle/caches/modules-2/files-2.1/io.reactivex/rxjava/1.1.0/748f0546d5c3c27f1aef07270ffea0c45f0c42a4/rxjava-1.1.0.jar
Run Code Online (Sandbox Code Playgroud)

为什么添加RxJava 1.1.0?

我可以排除rxjava.properties但我想了解错误.我已清理项目并使缓存无效,但错误仍然存​​在.

看图:

在此输入图像描述

谢谢

android rx-java rx-android

2
推荐指数
1
解决办法
2138
查看次数