Не удалось получить неизвестное свойство 'ANDROID_SDK_VERSION' для объекта типа org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler - PullRequest
0 голосов
/ 13 сентября 2018

У меня есть следующий проект ионного кордова:

/ мой-приложение / config.xml

<engine name="android" spec="^6.4.0" />
    <plugin name="cordova-plugin-device" spec="^1.1.7" />
    <plugin name="cordova-plugin-facebook4" spec="^2.4.0">
        <variable name="APP_ID" value="123456789" />
        <variable name="APP_NAME" value="my-app" />
    </plugin>
    <plugin name="cordova-plugin-ionic-webview" spec="^1.2.1" />
    <plugin name="cordova-plugin-splashscreen" spec="^4.1.0" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />

/ мой-приложение / package.json

"cordova": {
        "plugins": {
            "cordova-plugin-facebook4": {
                "APP_ID": "123456789",
                "APP_NAME": "my-app"
            },
            "cordova-plugin-device": {},
            "cordova-plugin-ionic-webview": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {}
        },
        "platforms": [
            "android"
        ]
    }

Когда я запускаю: enter code here Ионная информация

cli packages: (/usr/lib/node_modules)

    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

global packages:

    Cordova CLI : 7.0.1 

local packages:

    @ionic/app-scripts : 3.1.0
    Cordova Platforms  : android 6.4.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.11.4
    npm  : 5.6.0 
    OS   : Linux 4.15

Контекст : Когда я бегу: ionic cordova build android

> ionic cordova prepare
> cordova prepare
✔ Running command - done!

> cordova build android
✖ Running command - failed!
[ERROR] An error occurred while running cordova build android (exit code 1):


        ANDROID_HOME=/home/rreyes/android-sdk-linux
        JAVA_HOME=/usr/lib/jvm/java-8-oracle
        Subproject Path: CordovaLib
        The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use 
        Task.doLast(Action) instead.
            at build_8oeka4t56dp9oa43kn5u8er7z.run(/home/rreyes/workspace/tennis-up-app/platforms/android/build.gradle:141)

        FAILURE: Build failed with an exception.

        * Where:
        Build file '/home/rreyes/workspace/tennis-up-app/platforms/android/build.gradle' line: 255

        * What went wrong:
        A problem occurred evaluating root project 'android'.
        > Could not get unknown property 'ANDROID_SDK_VERSION' for object of type 
        org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

        * Get more help at https://help.gradle.org

        BUILD FAILED in 2s
        Error: /home/rreyes/workspace/tennis-up-app/platforms/android/gradlew: Command failed with exit code 1 Error 
        output:
        FAILURE: Build failed with an exception.

        * Where:
        Build file '/home/rreyes/workspace/tennis-up-app/platforms/android/build.gradle' line: 255

        * What went wrong:
        A problem occurred evaluating root project 'android'.
        > Could not get unknown property 'ANDROID_SDK_VERSION' for object of type 
        org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

        * Get more help at https://help.gradle.org

        BUILD FAILED in 2s

Я установил переменную env для ANDROID_SDK_VESION = "4. +"

Вопрос : Что мне нужно сделать, чтобы получить успешную сборку ionic cordova build android?

Заранее спасибо.

Ответы [ 2 ]

0 голосов
/ 23 февраля 2019

Проблема вызвана в основном тем, что плагин geolocation в cordova пытается удалить его и переустановить (последний) список плагинов cordova дает все плагины, плагин cordova rm будет удалять плагин.

setting properties (project.properties) file to the following might resolve the issue:
target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.google.android.gms:play-services-base:9.2.1
cordova.system.library.2=com.google.android.gms:play-services-ads:9.2.1
cordova.system.library.3=com.android.support:support-v4:24.1.1+
0 голосов
/ 10 декабря 2018

Вам необходимо установить переменную ANDROID_SDK_VESION в файле проекта build.gradle уровня проекта, или вы также можете определить ее в файле gradle.properties.

На уровне проекта build.gradle

project.ext { variableName = value }

Доступ к нему с помощью: project.ext.variablename

И в файле gradle.properties VariableName = value

Доступ к нему осуществляется с помощью: $variableName

...