I have a library which includes transitive libraries inside. I want to include this library to another project with JitPack.
First of all I prepared my code according JitPack's docs https://jitpack.io/docs/BUILDING/ and https://jitpack.io/docs/PRIVATE/
Then I created a private repository and uploaded there my library. Created release and installed gradle.
Then I get gradle dependency from JitPack, but it built with error:
BUILD SUCCESSFUL in 3m 16s
179 actionable tasks: 174 executed, 5 up-to-date
Build tool exit code: 0
Looking for artifacts...
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
Looking for pom.xml in build directory and ~/.m2
Found artifact: https://github.com/ilyinp:app:1.0.4
2020-01-21T05:25:55.722858568Z
Exit code: 0
ERROR: No build artifacts found
Expected artifacts in: $HOME/.m2/repository//github.com/ilyinp/app
Also on my computer I have directory $HOME/.m2/repository/https:/github/com/ilyinp/app/unspecified which contains files: app-unspecified.aar, app-unspecified.pom, app-unspecifed-javadoc.jar, app-unspecified-sources.jar
File app-unspecified.pom contains info about all third-party libs and my own transitive libs.
How to make JitPack builds work?
Related
I try to use Android Studio to build native c++ project using cmake 3.14.0 version. Like in documentation: https://developer.android.com/studio/projects/add-native-code#use_a_custom_cmake_version . So I add version "3.14.0" to my build.gradle and add cmake.dir=C\:\\CMakeWin32 to my local.properties about vanilla cmake.
And then:
> Task :UnitTests:generateJsonModelArmDebug
> Task :UnitTests:generateJsonModelArmDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':UnitTests:generateJsonModelArmDebug'.
> Illegal char <:> at index 47: C:/j/client/dava.framework/Programs/UnitTests\C:/r15c/sources/android/cpufeatures/cpu-features.c
If I use default cmake 3.6 in NDK bundle all works. My environment is:
Windows - 10
Android Studio - 3.4.1
gradle - try 4.10.1 and 5.4.1
ndk - try 15c and 19c
In my CMakeLists.txt I add dependency:
add_library( ${PROJECT_NAME} SHARED ${PLATFORM_ADDED_SRC} ${REMAINING_LIST} )
include(AndroidNdkModules)
android_ndk_import_module_cpufeatures()
target_link_libraries( ${PROJECT_NAME} cpufeatures)
I understand from error message full path to C:/r15c/sources/android/cpufeatures/cpu-features.c gradle want's to concatenate with path to current project C:/j/client/dava.framework/Programs/UnitTests. I think problem with gradle and how it use cmake_server to generate json code model. But how to fix it? Thanks in advance.
Update(more info):
If I build like: C:\j\client\dava.framework\Programs\UnitTests\Platforms\Android>gradlew :UnitTests:generateJsonModelArmDebug --info > log.txt 2>&1
in log file copy responce from cmake server and save it in file test.json
open test.json in Firefox and see target libcpufeatures.a in source section has full path to one source file.
sourceDirectory remainse from parent project C:/j/client/dava.framework/Programs/UnitTests
so I think gradle try to combine this two together bug in cmake or in gradle work with json responce from cmake.
Bug was in google gradle plugin so I just upgrade it and it works with new cmake 3.14.
Just update your gradle plugin:
dependencies { classpath 'com.android.tools.build:gradle:3.4.1' }
I have a problem with publishing multi-flavor library to jitpack.
The log says that build success but the status is error
I've followed instructions on jitpack site but their sample uses old gradle version and it did not work with gradle 4.4
Here is the log:
Build starting...
Start: Fri Apr 20 07:35:56 UTC 2018
Git:
1.28.1-1-g932f4d8
commit 932f4d88e13b1c8c52b4dbae8c203e7d52a0eadf
Author: yzheka
Date: Fri Apr 20 10:34:49 2018 +0300
jitpack config
Run gradle build
Gradle build script
Found gradle version: 4.4.
Using gradle wrapper
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Djavax.xml.accessExternalSchema=all
Downloading https://services.gradle.org/distributions/gradle-4.4-all.zip
..............................................................................................
Unzipping /home/jitpack/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4-all.zip to /home/jitpack/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1
Set executable permissions for: /home/jitpack/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4/bin/gradle
------------------------------------------------------------
Gradle 4.4
------------------------------------------------------------
Build time: 2017-12-06 09:05:06 UTC
Revision: cf7821a6f79f8e2a598df21780e3ff7ce8db2b82
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_131 (Oracle Corporation 25.131-b11)
OS: Linux 4.14.15-xxxx-std-ipv6-64 amd64
0m4.923s
Getting a list of gradle tasks
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Djavax.xml.accessExternalSchema=all
Running: ./gradlew clean -Pgroup=com.github.yzheka -Pversion=-1.28.1-g932f4d8-1 -xtest -xlint install
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Djavax.xml.accessExternalSchema=all
:clean
:app:clean UP-TO-DATE
:busybox:clean UP-TO-DATE
:busybox:install
BUILD SUCCESSFUL in 0s
4 actionable tasks: 2 executed, 2 up-to-date
Looking for artifacts...
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Djavax.xml.accessExternalSchema=all
EXIT_CODE=0
2018-04-20T07:36:32.030445377Z
Exit code: 0
No build artifacts found
In jitpack log you can see why jitpack can't publish your library. Just delete some part of your code because of jitpack error.
Cannot get the value of write-only property 'publishNonDefault' for object of type com.android.build.gradle.LibraryExtension.
if( android.publishNonDefault && variant.name == android.defaultPublishConfig ) {
def bundleTask = tasks["bundle${name.capitalize()}"]
artifacts {
archives(bundleTask.archivePath) {
classifier null
builtBy bundleTask
}
}
}
}
}
Then jitpack do not show the error when publishing your library. Works like a charm. To publish your library just realese once again then publish your libary.
I just made it for you as an example see the repository which I forked from you here https://github.com/markizdeviler/Busybox
This way is worked for me:
Add these line in the Module gradle after dependencies part :
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = 'com.github.yourgitid' //your git id
artifactId = 'Myket-Intent' //your-repository
version = '0.1.15' // same as Tag
}
}
}
}
after that you can see:
BUILD SUCCESSFUL in 41s
123 actionable tasks: 120 executed, 3 up-to-date
Build tool exit code: 0
Looking for artifacts...
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
Looking for pom.xml in build directory and ~/.m2
Found artifact: com.github.Mori-hub:Myket-Intent:0.1.15
2022-01-22T09:38:10.889110195Z
Exit code: 0
Build artifacts:
com.github.Mori-hub:Myket-Intent:0.1.15
I got an Android app for further development as a zip file. I unzipped and opened this in Jetbrains IDEA File> Open (Folder Address).
IDEA immediately realized that it was an android app.
This did not start.
Later I copied the gradle to C: \ Gradle and added it to the path (works well, see gradle -v in the screenshot).
But I still get errors below. How you could help. Thanks.
10:21 Frameworks Detected
Android framework is detected.
Configure
10:22 All files are up-to-date
10:22 Error running 'build': Module 'monkey' is not backed by gradle
10:23 All files are up-to-date
10:23 Error running 'build (1)': No jdk for module 'monkey-tree-app'
10:23 All files are up-to-date
10:23 Error running 'build': Module 'monkey-tree-app' is not backed by gradle
10:24 All files are up-to-date
10:24 Error running 'build': No jdk for module 'monkey-tree-app'
10:30 Error running 'Unnamed': No task to execute is specified
10:56 Error running 'Unnamed (1)': No task to execute is specified
I'm trying to get C++ code to work with react-native (see this for the general steps).
I've generated my project with react-native init, generated the JNI bindings by using Djinni. I'm now trying to build the application and test it on my android emulator (cd $PROJECT_ROOT/android && ./gradlew installDebug). It seems like the header files aren't found, their directories aren't included :
> ./gradlew installDebug
(...)
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk
Warning: Deprecated NDK integration enabled by useDeprecatedNdk flag in gradle.properties will be removed from Android Gradle plugin soon.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
http://tools.android.com/tech-docs/new-build-system/gradle-experimental.
In file included from $PROJECT_ROOT/android/app/src/main/jni/NativeCppBridgeText.cpp:4:
$PROJECT_ROOT/android/app/src/main/jni/NativeCppBridgeText.hpp:6:10: fatal error: 'cpp_bridge_text.hpp' file not found
#include "cpp_bridge_text.hpp"
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [$PROJECT_ROOT/android/app/build/intermediates/ndk/debug/obj/local/armeabi-v7a/objs/app/$PROJECT_ROOT/android/app/src/main/jni/NativeCppBridgeText.o] Error 1
:app:compileDebugNdk FAILED
FAILURE: Build failed with an exception.
I managed to get past this small issue by creating hard links to the headers causing issues. Which leads me to this :
> ./gradlew installDebug
(...)
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk
Warning: Deprecated NDK integration enabled by useDeprecatedNdk flag in gradle.properties will be removed from Android Gradle plugin soon.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
http://tools.android.com/tech-docs/new-build-system/gradle-experimental.
In file included from $PROJECT_ROOT/android/app/src/main/jni/NativeCppBridgeText.cpp:4:
In file included from $PROJECT_ROOT/android/app/src/main/jni/NativeCppBridgeText.hpp:7:
$PROJECT_ROOT/app/src/main/jni/djinni_support.hpp:20:10: fatal error: 'exception' file not found
#include <exception>
^~~~~~~~~~~
1 error generated.
make: *** [$PROJECT_ROOT/android/app/build/intermediates/ndk/debug/obj/local/armeabi-v7a/objs/app/$PROJECT_ROOT/android/app/src/main/jni/NativeCppBridgeText.o] Error 1
:app:compileDebugNdk FAILED
FAILURE: Build failed with an exception.
In this case, it seems like even standard libraries aren't included.
My question is : how do I explicitly specify gradle to add directories to its search/indlude path?
In regular Android projects, it seems that you can edit Android.mk/Application.mk files. There aren't such files in my folders ; I think that gradle actually generates an Android.mk file (in $PROJECT_ROOT/android/app/build/intermediates/ndk/debug/Android.mk), I tried editing it (LOCAL_C_INCLUDES field) to add my directories, but it gets overwritten when I try another build.
Thanks in advance.
You can edit this in $PROJECTROOT/android/app/build.gradle :
android {
defaultConfig {
(...)
ndk {
(...)
cFlags = "-Ipath/to/directory/"
}
}
}
However, you will most likely encounter other issues (I know that for a fact, because I did). I'd recommend you to use the modern and user-friendly CMake integration.
I'm gonna write down the general steps so that I can find it again sometime in the future :
Add your files to the android project (under android studio or another IDE). There should be files in your java/ folder, files in your jni/ folder (JNI bridge files), and files in your cpp/ folder (the native C++).
Add a CMakeLists.txt file to your module (usually named app if you're using react-native).
In this file, respect the following structure :
cmake_minimum_required(VERSION 3.4.1)
add_library( # Name of the library
$(YOUR_LIBRARY_NAME)
# Sets it as a shared library
SHARED
# Relative path to the source file(s)
path/to/your/file.cpp path/to/other/file.cpp )
# Allows you to add folders to the search path : similar to -Ipath/to/your/headerfolder/
include_directories(path/to/your/headerfolder/)
# Allows you to have special compilation flags for the specified library's compilation
target_compile_options( $(YOUR_LIBRARY_NAME)
PRIVATE # You can also use PUBLIC/INTERFACE
-std=gnu++11 ) # Your option ; I needed this in my case
Once it's done, you need to link gradle to your native library :
If you're using android studio, just use the information available in this guide as it's very well explained.
If you aren't, I also advise you to check out this guide, because it's really well explained.
After that, you can either build the project in android studio, or cd $(PROJECTROOT)/android && ./gradlew installDebug. It should work.
Good luck!
I have an aosp code copy, and do a full build some days ago,
recently I sync the code to the latest, and try to modify some code in Contacts module, and try to build it with:
mmm packages/apps/Contacts
there is an error:
1 error during configuration. Try --help-properties for help.
Property 'jack.library.import' (in Options): element #1: The version of the library file 'out/target/common/obj/JAVA_LIBRARIES/android-support-test_intermediates/classes.jack' is not supported anymore. Library version: 3.4 - Current version: 3.5 - Minimum compatible version: 3.5
ninja: build stopped: subcommand failed.
build/core/ninja.mk:84: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1
I search android-support-test in opengrok, and find android-support-test in prebuilts/misc/common/android-support-test
then I do:
mmm prebuilts/misc/common/android-support-test/
still error:
1 error during configuration. Try --help-properties for help.
Property 'jack.classpath': element #1: The version of the library file 'out/target/common/obj/JAVA_LIBRARIES/sdk_v23_intermediates/classes.jack' is not supported anymore. Library version: 3.4 - Current version: 3.5 - Minimum compatible version: 3.5
ninja: build stopped: subcommand failed.
build/core/ninja.mk:84: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1
but I can't find sdk_23 module in opengrok.
then I delete
out/target/common/obj/JAVA_LIBRARIES/android-support-test_intermediates/classes.jack
and do
make android-support-test
It doesn't rebuild the module.
So, how can I solve the dependency when using "mmm" building a module?
Looks like Jack keeps on not liking your prebuilt material (/out dir), is it from an entire different Android version?
I would suggest to do make clean OR just delete all /out/ directory from root repo.
Then do mma Contacts from root repo directory.
For further info on mm, mmm, mma, etc. Check build/envsetup.sh:
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
lunch: lunch <product_name>-<build_variant>
tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5] [eng|userdebug|user]
croot: Changes directory to the top of the tree.
m: Makes from the top of the tree.
mm: Builds all of the modules in the current directory, but not their dependencies.
mmm: Builds all of the modules in the supplied directories, but not their dependencies.
To limit the modules being built use the syntax: mmm dir/:target1,target2.
mma: Builds all of the modules in the current directory, and their dependencies.
mmma: Builds all of the modules in the supplied directories, and their dependencies.
cgrep: Greps on all local C/C++ files.
jgrep: Greps on all local Java files.
resgrep: Greps on all local res/*.xml files.
godir: Go to the directory containing a file.