Failed to create android project using gradle

I had a problem creating a simple android project using Gradle. My build file is below:

buildscript { repositories { mavenCentral() // To use a development snapshot version of the plugin, add the // Sonatype Snapshots repository. maven { url "https://oss.sonatype.org/content/repositories/snapshots" } } dependencies { classpath 'org.gradle.api.plugins:gradle-android-plugin:1.2.1' } } apply plugin: 'android' repositories { mavenCentral() } // Sets the package version version = "1.0.0" // Signing configuration, valid for all builds (1) androidSignAndAlign { keyStore = "path/to/my/keystore" keyAlias = "my-key-alias" keyStorePassword = "mystorepass" keyAliasPassword = "myaliaspass" } // Configure the filtering of resources with properties from the Gradle project scope (2) processResources { expand (project.properties) } // Configure a dedicated debug build (3) task configureDebug << { jar.classifier = "debug" } // Configure a dedicated release build (4) task configureRelease << { proguard.enabled = true } 

The error I am getting is this:

  11:08:24.812 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception. 11:08:24.822 [ERROR] [org.gradle.BuildExceptionReporter] 11:08:24.829 [ERROR] [org.gradle.BuildExceptionReporter] * Where: 11:08:24.834 [ERROR] [org.gradle.BuildExceptionReporter] Build file 'C:\Users\Work\AndroidProjects\RssUnified\build.gradle' line: 114 11:08:24.840 [ERROR] [org.gradle.BuildExceptionReporter] 11:08:24.845 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong: 11:08:24.850 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating root project 'RssUnified'. 11:08:24.855 [ERROR] [org.gradle.BuildExceptionReporter] > For input string: "21 rc11" 11:08:24.864 [ERROR] [org.gradle.BuildExceptionReporter] 11:08:24.870 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is: 11:08:24.875 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'RssUnified'. 11:08:24.880 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFac tory.java:54) 11:08:24.885 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.jav a:127) 

using gradle 1.2

edit: here is my xml file layout

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > </RelativeLayout> 

And here is the action

 public class RssListActivity extends Activity { /* * (non-Javadoc) * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.list_activity_layout); } } 

The structure of the project is below:

 β”œβ”€β”€β”€.gradle β”‚ └───1.2 β”‚ └───taskArtifacts β”œβ”€β”€β”€assets β”œβ”€β”€β”€bin β”‚ β”œβ”€β”€β”€classes β”‚ β”‚ └───com β”‚ β”‚ β”œβ”€β”€β”€jr β”‚ β”‚ β”‚ β”œβ”€β”€β”€screenLogic β”‚ β”‚ β”‚ └───screens β”‚ β”‚ └───richy β”‚ β”‚ └───rssunified β”‚ └───res β”œβ”€β”€β”€build β”‚ └───gen β”‚ └───com β”‚ └───richy β”‚ └───rssunified β”œβ”€β”€β”€gen β”‚ └───com β”‚ └───richy β”‚ └───rssunified β”œβ”€β”€β”€res β”‚ β”œβ”€β”€β”€drawable-hdpi β”‚ β”œβ”€β”€β”€drawable-ldpi β”‚ β”œβ”€β”€β”€drawable-mdpi β”‚ β”œβ”€β”€β”€drawable-xhdpi β”‚ β”œβ”€β”€β”€layout β”‚ β”œβ”€β”€β”€values β”‚ β”œβ”€β”€β”€values-v11 β”‚ └───values-v14 └───src └───com └───jr β”œβ”€β”€β”€screenLogic └───screens 

This is what is in the project root folder

 AndroidManifest.xml assets bin build build.gradle gen gradle.properties ic_launcher-web.png local.properties project.properties res src 

And finally, the android manifest:

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.richy.rssunified" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:theme="@style/AppTheme"> </application> </manifest> 

Local.properties

 sdk.dir = C:/Program Files (x86)/Android/android-sdk 

project.properties

 # This file is automatically generated by Android Tools. # Do not modify this file -- YOUR CHANGES WILL BE ERASED! # # This file must be checked in Version Control Systems. # # To customize properties used by the Ant build system edit # "ant.properties", and override values to adapt the script to your # project structure. # # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. target=android-15 

edit:

I returned back to the older version of the adt / sdk plugins and was able to fix the problems above, but after that I now got the above error:

 15:24:24.558 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :androidProcessResources FAILED 15:24:24.571 [ERROR] [org.gradle.BuildExceptionReporter] 15:24:24.575 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception. 15:24:24.582 [ERROR] [org.gradle.BuildExceptionReporter] 15:24:24.588 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong: 15:24:24.597 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':androidProcessResources'. 15:24:24.602 [ERROR] [org.gradle.BuildExceptionReporter] > Unexpected internal error near index 1 15:24:24.607 [ERROR] [org.gradle.BuildExceptionReporter] \ 15:24:24.613 [ERROR] [org.gradle.BuildExceptionReporter] ^ 15:24:24.621 [ERROR] [org.gradle.BuildExceptionReporter] 15:24:24.626 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is: 15:24:24.631 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':androidProcessResources'. 15:24:24.636 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecu ter.java:68) 
+4
source share
2 answers

As described in:
http://tools.android.com/tech-docs/new-build-system/using-the-new-build-system#TOC-Working-with-and-Customizing-SourceSets

The default source location is under src/<sourceset>

Your name is sourceset main , so the location is src/main

In addition, the manifest property is described:

manifest, enter AndroidSourceFile, the default location is src/<sourceset>/AndroidManifest.xml

I assume the manifest declaration:

  manifest { srcFile 'AndroidManifest.xml' } 

coincides with the position and ends with the location:

 src/main/AndroidManifest.xml 

which is indicated in the exception message.

I think this is how the plugin for Android works. gradle. Correct me if I am wrong, I do not know Gradle.

EDIT

OK, now I know what happened. Your build script mixes the settings with two different plugins.

Edit:

 classpath 'com.android.tools.build:gradle:0.1' 

to

 classpath 'org.gradle.api.plugins:gradle-android-plugin:1.2.1' 

Remove the android block, but save the body.

Remove the sourceSets block with the body.

Then it should work, I tested it this time.

EDIT 2

This is a Windows related error, fixed 6 days ago:

https://github.com/jvoegele/gradle-android-plugin/pull/89

what you can do is download the latest version of the plugin

 git clone git://github.com/jvoegele/gradle-android-plugin.git 

and install it in the local maven repository:

 gradle install 

then add mavenLocal() to the repository:

 repositories { mavenCentral() mavenLocal() } 

and change the plugin version to a snapshot:

 dependencies { classpath 'org.gradle.api.plugins:gradle-android-plugin:1.2.2-SNAPSHOT' } 
+5
source

It seems to me that you are trying to incorrectly escape the backslash in one of your Android resource files, as indicated in the androidProcessResources task. Please check your resource files or post them here so we can look at them.

0
source

Source: https://habr.com/ru/post/1443019/


All Articles