I am using Gradle 2.13 and trying to build android apk in readhat and system does not have internet access.
I am trying to build android apk offline. But it is throwing some exception and not able to figure out what went wrong.
Main build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'PROJECT'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.1.0.
Required by:
:PROJECT:unspecified
> No cached version of com.android.tools.build:gradle:2.1.0 available for offline mode.
> No cached version of com.android.tools.build:gradle:2.1.0 available for offline mode.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.831 secs
Version :
gradle -version
Gradle 2.13
Is there any tutorial available to build an offline apk in redhat/linux machine?
Edit: Update the question.
It happens because the gradle plugin for android 2.13 doesn't exist.
The latest stable version is 2.1.0. Use:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
Don't confuse gradle distribution and the android plugin for gradle.
You can define the gradle distribution used by a project in the file
gradle/wrapper/gradle-wrapper.properties
For example:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Related
I checked out and built the project at https://github.com/kosiara/artoolkit-android-studio-example
I have Android Studio 4.0.2 on Windows 10.
The build error I get is:
Executing tasks: [:app:assembleDebug] in project D:\Downloads\artoolkit-android-studio-example-master\artoolkit-android-studio-example-master
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':base'.
> Could not resolve all dependencies for configuration ':base:_debugCompile'.
> Could not find com.android.support:appcompat-v7:23.1.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.pom
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.jar
Required by:
artoolkit-android-studio-example-master:base:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.346 secs
I'm afraid I don't understand what is wrong.
I'm not sure what needs to be set to version 23.1.1. I looked in my Android SDK manager under SDK Tools, Android SDK Build-Tools and there is no option for 23.1.1. (Is that even where I should be looking?) I see 23.0.1, 23.0.2 (Installed), 23.0.3. Also the Android SDK Platform 23 is installed.
Do I need to add a custom Site to get the missing 23.1.1 option? I have no idea how to do that or what site it would be, if that's what's required.
I suspect there's likely something not set up correctly about my SDK or Android Studio, but I don't know what to check next.
I see this related question but that question has no answer.
I'd like some help getting this example to build.
That version of that module (appcompat-v7) is not in the JCenter repository.
You have to add google maven using the old way when you're using an old version of Gradle, you are not allowed to use google() on Gradle v1.5.
build.gradle (project level)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I tried compiling android but it gives me the following error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
> Could not resolve com.android.tools.build:aapt2:3.6.3-6040484.
Required by:
project :app
> No cached version of com.android.tools.build:aapt2:3.6.3-6040484 available for offline mode.
> No cached version of com.android.tools.build:aapt2:3.6.3-6040484 available for offline mode.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
I saw this web page https://discuss.gradle.org/t/cached-version-error/35754
It says I should increase kotlin version but when I went into the build.gradle of my app, I did not see any kotlin in it. This is the build.gradle of my app
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I don't think your issue is related to kotlin version. Looks like either you don't have a proper internet connection and your project its failing to download build tools 3.6.3 or you have "offline mode" enabled for gradle plugin.
If you are sure you have a proper internet connection, check if you have offline mode enabled in
Android Studio File -> Settings -> Build, Execution, Deployment -> Gradle
Or the quickest by just typing offline mode in the Android studio actions.
Hit shift + cmnd + a in Mac or shift + cntrl + a in windows.
Then type "offline mode"
Disable it
Sync gradle and run your proyect again.
This should solve the issue.
I'm getting error when i try to run android code in react native using react-native run-android.
I am running code on ubuntu.
rahul#rahul-Inspiron-15-3567 ~/Documents/reactNative/crowdalert/CrowdAlert-Mobile master ● react-native run-android
Scanning folders for symlinks in /home/rahul/Documents/reactNative/crowdalert/CrowdAlert-Mobile/node_modules (8ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
> Configure project :app
WARNING: The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..
Reading env from: .env
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> JAVA_LETTER_OR_DIGIT
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
running the app in react native too shows the same error.These are my versions of gradle and react-native:
react-native-cli: 2.0.1
react-native: 0.51.0
Gradle 4.4
Project level build.gradle file.
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.3.2'
classpath 'io.fabric.tools:gradle:1.25.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url "https://maven.google.com"
}
}
}
You probably have a version mismatch with your RN version and gradle. For ReactNative 0.51, you should use gradle 3.5. But this is not the only problem. Your project is out of date. You probably won't be able to publish your app to Google Play store, because Google introduced new publishing format (App Bundle) and your release apk will be rejected by the Play store. See more here: https://developer.android.com/platform/technology/app-bundle
To make that possible, you need to upgrade to gradle 5.5, and do that with React Native, you'll need to upgrade to 0.60+ version. See how to do that here: https://facebook.github.io/react-native/docs/upgrading
If you get lost upgrading the current project, alternative is to initialize a new project, link dependencies and c/p block-by-block of your code and adjust your code to new versions of libraries you use (if necessary).
Linux environment using jenkins android gradle project to build an error
* What went wrong:
A problem occurred configuring project ':app'.
> Could not download glide.jar (com.github.bumptech.glide:glide:3.7.0)
> Could not get resource 'https://jcenter.bintray.com/com/github/bumptech/glide/glide/3.7.0/glide-3.7.0.jar'.
> Could not GET 'https://jcenter.bintray.com/com/github/bumptech/glide/glide/3.7.0/glide-3.7.0.jar'.
> repo.jfrog.org: unknown error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I tried to use the wget way to download the link will prompt an error, then I use the sudo way to download the link successfully. So, how can I make jenkins gradle also use the sudo download, or use other solutions
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
// Exclude the version that the android plugin depends on.
configurations.classpath.exclude group: 'com.android.tools.external.lombok'
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Please help me, thanks.
You can try upload your local library (in user/.gradle/caches) to Jenkins server, It 's work for me.
I don't think that run the build with super user rights is a good solution, because it's not seems to be possible to resolve dependencies.
Just a suggestion how to solve it: Gradle has it's own local cache for dependencies and doesn't need to download them on every build. So you may use the same Gradle distribution, which is used by Jenkins, and once build your application manually with su rights, to resolve all dependencies and cache them.
Just to note, by default dependencies with dynamic versions are cached for 24 hours only, as it's said in the official docs, but you can change it as:
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 10, 'minutes'
resolutionStrategy.cacheChangingModulesFor 4, 'hours'
}
when I use gradle(version 2.1 or 2.4) building Android Project, get the error below. I can not find com.android.support:multidex:1.0.1 in my files.
ERRORS:
config is set to BF688C717A5C3A69FE8CA522643C0A68
config is set to PRODUCT
vcode is set to 151
vname is set to 1.5.1
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':XXXX'.
Could not resolve all dependencies for configuration
':yizhangtong:_rendepeng_lmDebugCompile'.
Could not find com.android.support:multidex:1.0.1.
Searched in the following locations:
.............
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 30.178 secs
You need to install "Android Support Repository" from the Android SDK manager. (a.k.a extra-android-m2repository if installing from the command line)
**OR**
You need to install "Android Support Library(Obsolete)" from the Android SDK manager.
This issue exists in Android studio Beta versions
The only solution is to use
repositories {
maven {
url 'https://maven.google.com'
}
}
in project gradle file
Installing both Android Support Library and Local Maven Repository for Support Libraries from the Android SDK manager (Extras section) fixed this issue for me.
If you are using Android SDK command line tools, type:
sdkmanager "extras;android;m2repository"
The SDK manager will install the m2 repository
try compile 'com.android.support:multidex:1.0.0'
I fixed it by adding google() in allprojects node on top-level build.gradle file. Here is my top level file for reference
buildscript {
repositories {
jcenter()
mavenLocal()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}