Qt compiler reports invalid build tools version for Android - android

I have been developing Android applications using Eclipse/Android Studio. Now, I am exploring building an application using QT. I installed QT and configured it for Android as explained at http://qt-project.org/wiki/Qt5ForAndroidBuilding. I later my first Android app using "QT Quick Application" template. When I compile it from QT Creator, I get the following error:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\MyQtApps\build-MyTest1-Android_for_armeabi_v7a_GCC_4_8_Qt_5_4_1-Debug\android-build\build.gradle' line: 39
* What went wrong:
A problem occurred evaluating root project 'android-build'.
> Invalid revision: build-tools-21.1.2
Android build tools version 21.1.2 is present on the machine. In fact, my SDK and all other Android tools are completely up to date.
Next, from the options dialog, I turned "Use Gradle" off and entered the path for Ant executable. After that, I proceeded to create a new project. This project builds and deploys fine on my mobile device.
Looks like the problem is with Gradle integration. For now, I can simply go with Ant but would be nice to have it fixed. Any suggestions? Regards.

For those who are running into this problem (and I assume this includes everyone who is using Qt for Android development), the solution is to fix Qt-generated gradle.properties file. This file contains the following line:
androidBuildToolsVersion=build-tools-21.1.2
File build.gradle tries to use this variable as:
android {
...
buildToolsVersion androidBuildToolsVersion
...
}
Function buildToolsVersion expects a value such as 21.1.2 and not build-tools-21.1.2. So the fix is to edit gradle.properties file as:
androidBuildToolsVersion=21.1.2
I still don't know where Qt Creator picks up 21.1.2 from. In my case, I used the following setting:
androidBuildToolsVersion=23.0.0
Now, things work as expected.

In addition to Peter solution:
You can change in the android/gradle.properties the androidBuildToolsVersion to the desired one.
Note: You have to edit the file via shell because it doesn't appear in the qt creator (at least in the 5.9 version)

Related

Xamarin android project "java.exe" exited with code 1

I want to build my xamarin android application with android 12 target framework on release mode. The build fails with the following
"Xamarin.Android.D8.targets(51,5): error MSB6006:"java.exe" exited
with code 1."
error.
Solutions I've tried so far are :
1 - Download the latest proguard version and replace the files inside /android-sdk/tools/proguard and create a proguard config file under android project making sure the file is saved with UTF-8.
2 - Make sure all the nuget packages are compatible by creating a blank sample project and adding each nuget from my original project and make sure it builds.
3 - Delete bin and object files and rebuild the project.
Doing some online research that I've found out that this particular version (Xamarin.Android.D8.targets(51,5)) of the 'java.exe exited with code 1' error type is mostly associated with either proguard or incompability however I am unable to locate the source of the problem, any kind of help is appreciated.
Here are some relevant information:
I do have the msbuild output level set to diagnostics but i don't think i can share the whole 260k line output file. Linking is set to "Sdk assemblies only".
SDK
JDK
Android Options
6 > Done executing task "WriteLinesToFile".
6 > Done building target"_CleanRecordFileWrites" in project "TestApp1.Android.csproj".
6 > Build FAILED.
6 >
"C:\Users\TestUser\source\Workspaces\TestApp1\TestApp1.Android\TestApp1.Android.csproj"
(Rebuild;BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;DebugSymbolsProjectOutputGroup;DebugSymbolsProjectOutputGroupDependencies;DocumentationProjectOutputGroup;DocumentationProjectOutputGroupDependencies;SatelliteDllsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;SGenFilesOutputGroup;SGenFilesOutputGroupDependencies
target) (1) ->
6 > (_CompileToDalvik target) ->
6 > C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.D8.targets(51,5):
error MSB6006: "java.exe" exited with code 1.
11 Warning(s)
1 Error(s)
6>Time Elapsed 00:00:58.23
========== Rebuild All: 5 succeeded, 1 failed, 0 skipped ==========
There is no output from proguard inside the build output.
I've found the problem. The project was developed on android 11 and could build without a problem, the problem began when the target framework version was changed android 12, first the build error was:
'Xamarin.Android.Support.v4' is using '[assembly:
Java.Interop.JavaLibraryReferenceAttribute]' , which is no longer
supported. Use a newer version of this NuGet package or notify the
library author.
So we made sure that all nuget packages could run on android 12 than the build error changed to:
is also present at androidmanifest.xml:22:18-91 value (android.support.v4.app.corecomponentfactory)
this is was just one of the several java errors and all the errors were related to android.support.v4.app library. So during my first research I've found from the in xamarin community that some were able to solve their problem by adding the code :
tools:node="replace"
to their AndroidManifest.xml file under the <application> tag. So I did just that to see the results and the error than changed to:
"java.exe" exited with code 1
after going back to the first "android.support.v4.app" error and doing some more research about it online I've found that android studio users could solve these type of errors by setting the "useAndroidX = true" in their build.gradle file. Not having a build.gradle file in my project I've just decided delete the code I previously added to my AndroidManifest.xml and to add the "Xamarin.AndroidX.Core" Nuget package to my android project, after doing so the error changed to:
Could not find Jetbrains.Annotations
So after also adding the "Xamarin.Jetbrains.Annotations" nuget package to my project ,it now builds without an error.

Delete unaligned apks using Gradle script in Android Studio 3.0?

After upgrading to Android Studio 3.0/build tools 3.0.0, a piece of my Gradle build script (which is used to delete unaligned apks after assembling) failed during build.
FYI I was using the Gradle scripts from this post.
Now it's always saying output.packageApplication.outputFile is an unknown property (Could not get unknown property 'outputFile' for task...).
I am wondering if there's an alternative way to get the unaligned file?
Any comment is appreciated, thanks in advance.
As of Gradle 2.2, there isn't an unaligned APK, so deleting it is unnecessary. (I just ran into this also - and noticed that they were missing.)
See the note here:
https://issuetracker.google.com/issues/37121010
So your code to remove them is unnecessary.
Also, to address the failure - as of Gradle 3.0 there are some features that are not working (like the variant outputFile). See the reference here on how to avoid that error:
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#variant_api

Netbeans 8.1, Gluon Project Android Error

I'm using Netbeans 8.1, with gluon and nbandroid plugins, on Windows 8.1, and when I create a gluon basic project i can't run on Android platform, the error are about ANDROID_HOME, in the last two days I have searched a lot about it but all the tries I have made don't help.
Here is the error:
Caused by: org.gradle.internal.exceptions.LocationAwareException: ANDROID_HOME not specified. Either set it as a gradle property, a system environment variable or directly in your build.gradle by setting the extension jfxmobile.android.androidSdk.
Caused by: org.gradle.api.GradleException: ANDROID_HOME not specified. Either set it as a gradle property, a system environment variable or directly in your build.gradle by setting the extension jfxmobile.android.androidSdk.
I tried the sample project from gluon, and the error still appears, but if I create an Android project (nbandroid, not gluon) and run it, everything is ok.
I see same difference from other questions on the project, when I create a gluon basic project automatically a Android project is created, but i don't see that on a lot of movies i watch on Youtube.
Can anyone help me, please? If more data is needed, I can upload it.
You can have a look at the JavaFXPorts documentation on the prerequisites to get started.
There are several options on how to set ANDROID_HOME. Basically:
Define the androidSdk property under jfxmobile.android in build.gradle:
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = 'C:/<path to>/Android/sdk'
}
}
Or create a file named grade.properties, and place it in your local gradle folder (C:/Users/<user>/.gradle), adding this property:
ANDROID_HOME=C:/<path to>/Android/sdk
If you use the second option, you won't need to take care of adding it all the time on new projects.
Also you will find this local file added on your NetBeans projects, in a Gradle Home folder:

Gradle execution fails: Unknown command-line option '--daemon'

I use latest Android Studio (0.8.2). On my other PC the same code is successfully builded.
It means that build scripts are correct.
So I assume that it is something with Gradle configuration, but I double rechecked all configs:
I completely removed .gradle folder under C:\Windows\Users{MyUser}.gradle to delete old configurations;
gradle.properties file doesn`t have any uncommented options
What do I miss?
NOTE! I have not specified '--daemon' option. Or I only think so:( I can`t find it in Gradle default and project specific settings
Also I created absolutely new project in the studio. It didn`t help - the same error(
The answer is very simple. It seems that new version of Android studio imported all setting from previous one. Some of old options added additional options to compiler
Android Studio always uses a Gradle daemon. It connects to the daemon via the Gradle Tooling API, and perhaps the latter doesn't understand --daemon (because it's redundant).

What could be causing the "OutputPath property is not set for project ProjectName.csproj" error in my MonoDevelop project

On Windows 7 (64 bit) with the Android SDK working perfectly with Eclipse - my first android application, using the first "Hello World" sample (found here - http://docs.xamarin.com/android/getting_started/hello_world - from Xamarin)
fails with the error "the OutputPath property who is not set for project NameProject.csproj".
I have tried re-runing the installation program from Xamarin and this error still occurs.
Could someone please suggest what may be causing this problem?
Thanks a lot.
the exact error:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(9,9):
Error: The OutputPath property is not set for project 'helloWorld3.csproj'.
Please check to make sure that you have specified a valid combination of
Configuration and Platform for this project.
Configuration='Debug'
Platform='BPC'.
This error may also appear if some other project is trying to follow a
project-to-project reference to this project, this project has been
unloaded or is not included in the solution, and the referencing project
does not build using the same or an equivalent Configuration or Platform.
(helloWorld3)
I think we've seen this before. Your system manufacturer installed an environment variable called Platform onto your system. This breaks all msbuild based stuff, since msbuild automatically imports that as $(Platform), conflicting with the real $(Platform) that msbuild uses to compile.
Try removing the environment variable and try again.

Categories

Resources