android – play_licensing使用Gradle将APK扩展为downloader_library抛出AIDL错误

前端之家收集整理的这篇文章主要介绍了android – play_licensing使用Gradle将APK扩展为downloader_library抛出AIDL错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试使用APK Expansion libs zip_file和downloader_library(需要play_licensing). zip_file工作正常,因为它没有依赖项,但是当我尝试Gradle同步时,play_licensing会引发错误.

Android Studio吐出此错误日志:

Information:Gradle tasks [:app:generateGoogleDebugSources,:app:libs:downloader_library:generateDebugSources,:app:libs:play_licensing:generateDebugSources,:app:libs:zip_file:generateDebugSources]
Information:/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicenseResultListener.aidl:21 interface ILicenseResultListener should be declared in a file called com/android/vending/licensing/ILicenseResultListener.aidl.
Information:2 errors
Information:0 warnings
Information:See complete output in console
/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicensingService.aidl
Error:(19) couldn't find import for class com.android.vending.licensing.ILicenseResultListener
Error:(19) Execution Failed for task ':app:libs:play_licensing:compileReleaseAidl'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/faiz/Projects/Android/android-sdk-macosx/build-tools/19.0.3/aidl -p/Users/faiz/Projects/Android/android-sdk-macosx/platforms/android-19/framework.aidl -o/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/build/source/aidl/release -I/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl -I/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/src/release/aidl -d/var/folders/y6/g0d5m3f94rxdvq5myp53d9k80000gn/T/aidl662748145109587430.d /Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicensingService.aidl

Error Code:
  1

Output:
/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicensingService.aidl:19: couldn't find import for class com.android.vending.licensing.ILicenseResultListener

我没有修改任何库,但由于它们不是为Gradle构建的,我从另一个项目复制了build.gradle并相应地修改它们.

downloader_library /的build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:+'
    compile project(':app:libs:play_licensing')
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }

    defaultConfig {
        minSdkVersion 4
        targetSdkVersion 19
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.txt'
        }
    }
}

play_licensing /的build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:+'
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
            aidl.srcDirs = ['aidl']
        }
    }

    defaultConfig {
        minSdkVersion 3
        targetSdkVersion 19
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.txt'
        }
    }
}

我目前正在使用Android Studio 0.5.1和gradle 0.9.0以及构建工具19.0.3

解决方法

我遇到了同样的问题并找到了解决方案.只需在aidl文件夹下创建一个名为com.android.vending.licensing的新包,然后将您的aidl文件移动到那里:

附:你还必须添加空< application />标记到play_licensing和downloader_library模块的AndroidManifest.xml.并将项目(‘:PlayLicensing’)编译为downloader_library的build.gradle的dependencies标记

猜你在找的Android相关文章