Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apk Variant Output #14

Closed
lordmyke opened this issue Oct 30, 2017 · 8 comments
Closed

Apk Variant Output #14

lordmyke opened this issue Oct 30, 2017 · 8 comments

Comments

@lordmyke
Copy link

I'm getting this build error:
Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.

How can i fix this?

@robdaven
Copy link

robdaven commented Nov 5, 2017

In Android Studio open "artifacts.gradle".

Change this:
gradle41update

To this:
gradle41update2

Then resync Gradle. It will give you sync errors:
gradle41update3

Click "Update Build Tools version and sync project" for each of the errors. It will take a few times to clear the list.

@robdaven
Copy link

This problem still exists in 1.0.7

@brian-ross
Copy link

This issue to due to using a newer version of gradle with Android Studio 3 and above. Changing the artifacts.gradle file as indicated in #14 is correct. However, you also may have to update your gradle version of the project. If you don't want to do this, use an older version of Android Studio; earlier than Version 3.

@iknowzo
Copy link

iknowzo commented Jul 3, 2019

I did this and now I'm getting this error: Gradle DSL method not found: 'deleteAllActions()'

Not sure how to fix this, I'm not getting the option to update build tools version

@levonlevonian
Copy link

Hi iknowzo,

Please see the following forum thread where I answered a similar question (see the first comment under the original question):
https://forums.developer.amazon.com/questions/93948/cannot-set-the-value-of-read-only-property-outputf.html?childToView=205687#comment-205687

@HelaGone
Copy link

HelaGone commented Jul 12, 2019

Hi @levonlevonian
I'm facing some issues here related to this thread.

I'm working on Android Studio 3.4.2 with the Fire App Builder to develop our Fire Tv application.
Out of the box the Fire App Builder can't build an APK even before I touch any code.
The issue was the "Unsupported version of Gradle". So, I upgraded the Gradle version to 3.4.2. After hit click on Sync project button, another error poped up that states that the "Minimum supported Gradle version is 5.1.1" So I went to graddle-wrapper.properties file and upgraded the Gradle version to 5.1.1-all.zip. Then I hit the Sync project button and the console says that "Cannot set the valur of read-only property 'outputFile' for APKVAriantOutput…" So, after some googling I stumble upon this thread and followed the @robdaven instructions. After hitting the sync button again the error says that the "Gradle DSL method not found 'deleteAllActions()'", So I tracked the issue down to the Amazon's forum that you point. I've added the google() repo but the same error stands.

I've tried to Clean & Rebuild the project, but I only get a lot of warnings complaining about a bunch of deprecated methods. I guess that happens when you try to work with outdated forks of Android on an Updated Android Studio Environment

I've even tried to match the versions you used in your responses but It still complains about mismatched Gradle versions.

Obviously I'm not going to downgrade Android Studio just for this development. Is there a workaround for this or I would need to use an old version of Android to be able to develop an app for Fire Tv?

@levonlevonian
Copy link

levonlevonian commented Jul 16, 2019

Hi @HelaGone

For Gradle, are you using a wrapper or a local distribution? You can check that in Preferences, under "Build, Execution, Deployment", and then "Gradle".

If you are using the wrapper, then normally Android Studio offers to update the wrapper for you if you click on the error telling you that it is not a supported version. Otherwise, go to /gradle/wrapper/gradle-wrapper.properties file, which contains a line that will look something like this: distributionUrl=https://services.gradle.org/distributions/gradle-X.Y.Z-all.zip -- here change the version at the end to a supported version.

If you are using the local distribution, then again you will need to update your local Gradle to a supported version, or ideally switch to using the wrapper, which is a recommended way.

It's not clear what you mean by "or I would need to use an old version of Android to be able to develop an app for Fire Tv?" What device and OS version are you testing your app on? Normally, you would connect to your Fire TV and build, run and test your app directly on it. Thanks!

@HelaGone
Copy link

Hi @levonlevonian
I'm testing the application on a Fire Stick Gen 2. The application runs perfectly when I side load it to the Fire Stick.

For Gradle I'm using the one that comes with the Fire App Builder, which is the wrapper.
Indeed, for testing purposes, I've downloaded the Fire App Builder, build the project as is and tried to generate the APK but I got the same issue. It can't compile the APK due to the errors in Gradle's compatibility.

After try your suggestions I stumble on this error:
Gradle DSL method not found: 'deleteAllActions()'

Which is the same isse described by @iknowzo. I've followed the link you provide, and did the changes accordingly, but the error persists.

This is the output:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':ContentBrowser'.

Caused by: com.android.build.gradle.internal.crash.ExternalApiUsageException: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method deleteAllActions() for arguments [] on task ':ContentBrowser:extractDebugAnnotations' of type com.android.build.gradle.tasks.ExtractAnnotations.

Here's my setup:
at gradle-wrapper.properties:
distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-all.zip

at build.gradle (Project: Application):

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        if (rootProject.hasProperty('mavenUrl')) {
            maven { url rootProject.mavenUrl }
        }
    }
}

at artifacts.gradle:

android.applicationVariants.all { variant ->
    def appName
    // Use applicationName if available, else use parent name
    if (project.hasProperty("applicationName")) {
        appName = applicationName
    } else {
        appName = parent.name
    }

    variant.outputs.all { output ->
        def newApkName
        if (output.zipAlign) {
            newApkName = "${appName}-${output.baseName}-${variant.versionName}.apk"
        } else {
            newApkName = "${appName}-${output.baseName}-${variant.versionName}-unaligned.apk"
        }
        outputFileName = new File(output.outputFileName, newApkName)
    }
}

at build.gradle (Module: app)

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
// Uncomment when using CrashlyticsComponent
//apply plugin: 'io.fabric'
apply from: "../artifacts.gradle"

repositories {
    // Uncomment when using CrashlyticsComponent
    //maven { url 'https://maven.fabric.io/public' }
}

buildscript {
    repositories {
        jcenter()
        // Uncomment when using CrashlyticsComponent
        //maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'me.tatarka:gradle-retrolambda:3.2.3'
        // Uncomment when using CrashlyticsComponent
        //classpath 'io.fabric.tools:gradle:1.+'
    }
}

android {
    compileSdkVersion 26
    buildToolsVersion "25.0.0"

    defaultConfig {
        applicationId "com.fireappbuilder.android.noticieros"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 10
        versionName "1.0.7"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            testCoverageEnabled = true
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    // this is for jackson
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
        exclude 'META-INF/services/com.fasterxml.jackson.core.ObjectCodec'
        exclude 'META-INF/rxjava.properties'
    }

    lintOptions {
        abortOnError false
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile 'junit:junit:4.12'
    androidTestCompile 'org.mockito:mockito-core:1.9.5'
    androidTestCompile ('com.android.support.test:rules:0.5') {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestCompile ('com.android.support.test:runner:0.5') {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'

    androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1'

    compile project(':TVUIComponent')
    compile project(':UAMP')
    compile project(':AMZNMediaPlayerComponent')
    compile project(':PassThroughAdsComponent')
    compile project(':PassThroughLoginComponent')
    compile project(':GoogleAnalyticsComponent')
}

Let me know if this make sense or am I missing something?
Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants