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

Build with --gradleArg=-PcdvCompileSdkVersion=?? not working #657

Closed
brodybits opened this issue Feb 10, 2019 · 6 comments
Closed

Build with --gradleArg=-PcdvCompileSdkVersion=?? not working #657

brodybits opened this issue Feb 10, 2019 · 6 comments

Comments

@brodybits
Copy link
Contributor

brodybits commented Feb 10, 2019

For example:

cordova build android -- --gradleArg=-PcdvCompileSdkVersion=27

produces an error like this:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find target with hash string '27' in: /Users/brodybits/Library/Android/sdk

same issue on cordova-android@latest (7.1.4), 7.0.0, and nightly (cordova-android@8.0.0-nightly.2019.2.10.a6f30b69)

ref: https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#setting-gradle-properties

P.S. I discovered this issue during rework in response to review comments on PR #655.

P.P.S. This was observed in bash terminal on mac OS (10.13.6).

P.P.P.S. This is an issue with using --gradleArg=-PcdvCompileSdkVersion=??, not an issue with using --gradleArg=-PcdvMinSdkVersion=??.

I think this difference is due to the fact that bin/templates/project/app/build.gradle does the corrective casting for cdvMinSdkVersion but not for cdvCompileSdkVersion. (The corrective casting for cdvMinSdkVersion was already done in PR #551.)

@brodybits
Copy link
Contributor Author

The following change should resolve this issue but would interfere with changes proposed in #657:

--- a/bin/templates/project/app/build.gradle
+++ b/bin/templates/project/app/build.gradle
@@ -122,6 +122,7 @@ if (ext.cdvReleaseSigningPropertiesFile == null && file('../release-signing.prop
 ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean();
 ext.cdvVersionCodeForceAbiDigit = cdvVersionCodeForceAbiDigit == null ? false : cdvVersionCodeForceAbiDigit.toBoolean();
 ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? defaultMinSdkVersion : Integer.parseInt('' + cdvMinSdkVersion)
+ext.cdvCompileSdkVersion = Integer.parseInt('' + ext.cdvCompileSdkVersion)
 ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)
 
 def computeBuildTargetName(debugBuild) {

@erisu
Copy link
Member

erisu commented Feb 10, 2019

Cordova version: 8.1.1
Cordova-Android version: 8.0.0-nightly.2019.2.10.a6f30b69

Creating Cordova project for the Android platform:
	Path: platforms/android
	Package: ....
	Name: androidTest
	Activity: MainActivity
	Android target: android-28

$ cordova build android -- --gradleArg=-PcdvMinSdkVersion=27

Checking Java JDK and Android SDK versions
ANDROID_HOME=/Users/dev/android/sdk
Subproject Path: CordovaLib
Subproject Path: app
> Task :app:preBuild UP-TO-DATE
> Task :CordovaLib:preBuild UP-TO-DATE
> Task :CordovaLib:preDebugBuild UP-TO-DATE
> Task :CordovaLib:checkDebugManifest
> Task :CordovaLib:processDebugManifest
> Task :app:preDebugBuild
> Task :CordovaLib:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :CordovaLib:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript
> Task :app:checkDebugManifest
> Task :app:generateDebugBuildConfig
> Task :app:prepareLintJar
> Task :app:generateDebugSources
> Task :CordovaLib:compileDebugRenderscript
> Task :CordovaLib:generateDebugBuildConfig
> Task :CordovaLib:generateDebugResValues
> Task :CordovaLib:generateDebugResources
> Task :CordovaLib:packageDebugResources
> Task :CordovaLib:generateDebugRFile
> Task :CordovaLib:prepareLintJar
> Task :CordovaLib:generateDebugSources
> Task :CordovaLib:javaPreCompileDebug

> Task :CordovaLib:compileDebugJavaWithJavac

Note: /Users/dev/androidTest/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :CordovaLib:processDebugJavaRes NO-SOURCE
> Task :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug
> Task :app:javaPreCompileDebug
> Task :app:mainApkListPersistenceDebug
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:mergeDebugResources
> Task :app:createDebugCompatibleScreenManifests
> Task :app:processDebugManifest
> Task :app:processDebugResources
> Task :app:compileDebugJavaWithJavac
> Task :app:compileDebugNdk NO-SOURCE
> Task :app:compileDebugSources
> Task :app:mergeDebugShaders
> Task :app:compileDebugShaders
> Task :app:generateDebugAssets
> Task :CordovaLib:mergeDebugShaders
> Task :CordovaLib:compileDebugShaders
> Task :CordovaLib:generateDebugAssets
> Task :CordovaLib:packageDebugAssets
> Task :app:mergeDebugAssets
> Task :app:validateSigningDebug
> Task :app:signingConfigWriterDebug
> Task :app:transformClassesWithDexBuilderForDebug
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug
> Task :app:transformDexArchiveWithDexMergerForDebug
> Task :app:mergeDebugJniLibFolders
> Task :CordovaLib:compileDebugNdk NO-SOURCE
> Task :CordovaLib:mergeDebugJniLibFolders
> Task :CordovaLib:transformNativeLibsWithMergeJniLibsForDebug
> Task :CordovaLib:transformNativeLibsWithStripDebugSymbolForDebug
> Task :CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug
> Task :app:transformNativeLibsWithMergeJniLibsForDebug
> Task :app:transformNativeLibsWithStripDebugSymbolForDebug
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:transformResourcesWithMergeJavaResForDebug
> Task :app:packageDebug
> Task :app:assembleDebug
> Task :app:cdvBuildDebug

BUILD SUCCESSFUL in 7s
44 actionable tasks: 44 executed
Built the following apk(s):
	/Users/dev/androidTest/platforms/android/app/build/outputs/apk/debug/app-debug.apk

@brodybits
Copy link
Contributor Author

Hi @erisu your command is slightly different. I also have success with --gradleArg=-PcdvMinSdkVersion=27.

To reproduce please be sure to try with --gradleArg=-PcdvCompileSdkVersion=27 like I show in the description.

In case you do have success with --gradleArg=-PcdvCompileSdkVersion=27, it would be great if you could share your system OS, OS version, and what kind of shell it succeeds on.

I just updated the description with some more information about the issue with cdvCompileSdkVersion vs cdvMinSdkVersion.

brodybits pushed a commit to brodybits/cordova-android that referenced this issue Feb 10, 2019
@brodybits
Copy link
Contributor Author

Another factor is that compileSdkVersion and targetSdkVersion are not always the same thing. I discovered a very interesting article at: https://medium.com/androiddevelopers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd

@Chuckytuh
Copy link
Contributor

I've been delving into those gradleArgs myself for the past week and what I've discovered is that it works by providing -- --gradleArg=-PcdvCompileSdkVersion=android-28

@erisu
Copy link
Member

erisu commented Jul 21, 2021

Closing this ticket for the recent changes in Cordova-Android 10: #1212

targetSdkVersion and compileSdkVersion was unified and the cdvCompileSdkVersion was removed.

@erisu erisu closed this as completed Jul 21, 2021
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

3 participants