I don't know what exactly causes this error but i've searched everywhere and nothing can solve it, it getting worst! When i build my app it shows AAPT2 error: check logs for details. See the screenshots.
My project build.gradle file
// 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.1.3'
// classpath 'com.android.tools.build:gradle:3.2.0-alpha13'
// classpath 'com.android.tools.build:gradle:3.1.4'
//classpath 'com.android.tools.build:gradle:3.2.0-alpha11'
// 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
}
And my app build.gradle file
// 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.1.3'
// classpath 'com.android.tools.build:gradle:3.2.0-alpha13'
// classpath 'com.android.tools.build:gradle:3.1.4'
//classpath 'com.android.tools.build:gradle:3.2.0-alpha11'
// 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 am in the middle of my thesis and it causes me a big big problem. Please help me!
Add this line in your gradle.properties file
android.enableAapt2=true
Look at what the errors are - in the second picture you attached there are 3 Android issues (the three last issues in the window on the left side). They are saying that there's a problem with some 3 attributes. If you click onto them you will be able to see the whole error and then fix the issue.
To trace error
try running the following command in your project directory
gradlew assembleDebug
Related
I created a new Android project by importing one of our company projects today. I am not an Android programmer but I had to run it and measure performance. So I installed Android Studio today on my Ubuntu 18.04 box. I also update plugins.
During the first Gradle sync, there was an error:
Could not GET 'http://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.50/kotlin-stdlib-jdk8-1.3.50.pom'. Received status code 403 from server: Forbidden
The build.gradle file looks like the following:
buildscript {
repositories {
jcenter { url "http://jcenter.bintray.com" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
allprojects {
repositories {
jcenter { url "http://jcenter.bintray.com" }
google()
}
}
With my Chrome,
I cannot access 'http://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.50/kotlin-stdlib-jdk8-1.3.50.pom'
but I can download pom file with https with by browser.
So I tried to change http to https in the above build.gradle but got the following errors:
Repository not found.
Process command 'git' finished with non-zero exit value 1
I searched and tried the following:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
I also tried to add some url in maven{ url ... } but got the same error (Repository not found.)
Please help me how to successfully finish gradle sync.
Thank you!
This is an answer to my question.
I found that there are some proxy setting in gradle.property file and now it works.
you need to use proxy
you can go to File>settings and search HTTP proxy and select Manual proxy configuration and Http
now you will be set Host name and Port number:::
Host : mirror.vtwo.org , mirror1.vtwo.org --> Port : 8850
Proxy Server : fodev.org --> Proxy Port : 8118
Proxy Server : mirror.mbaas.ir --> Proxy Port : 8700
Proxy Server : android.hive.ir --> Proxy Port : 8080
I have set up a brand new project in Android Studio 1.1 RC 1:
Created an Android project [app] (because there is no way to create an App Engine backend project right away).
Added an existing backend module by first creating a new App Engine module and then manually importing the files [backend].
Removed the Android app module [app].
Added a Java library module, same procedure, first creating a new module, then importing files [common].
Everything compiles fine, but Android Studio has two problems:
When I look at Project Structure, the [common] module is missing in the left pane, but it still appears as referenced module in the right pane!?
My Project tree looks fine and all modules are recognized, but gradle is telling me the sync failed.
Gradle says "Task '' not found in root project" ('' is empty string as it seems). I get a Warning and an exception in the log when running from Terminal, but it doesn't seem to be related (related to Indexing), so I haven't included it here.
settings.gradle has both modules specified:
include ':backend', ':common'
I tried to exchange the .iml file of the main project with a fake one which contains both modules, with the result that (besides multiple side effects) both modules were there. (I restored the original state because of the side-effects.)
Here are my gradle files:
Root module:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
}
}
allprojects {
repositories {
jcenter()
}
}
[backend]
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.17'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.17'
compile 'com.google.appengine:appengine-endpoints:1.9.17'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.17'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.googlecode.objectify:objectify:5.1.3'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'io.jsonwebtoken:jjwt:0.4'
compile project(':common')
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
[common]
apply plugin: 'java'
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
dependencies {
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
compile 'com.google.code.gson:gson:2.3.1'
}
apply plugin: 'maven'
group = 'cc.closeup'
version = 'v2-2.0-SNAPSHOT'
install {
repositories.mavenInstaller {
pom.artifactId = 'common'
pom.packaging = 'jar'
}
}
Any ideas? Anything else that you'd like to see here?
If you want to build an AE project only. You could try this tutorial for intellij idea jetbrains.com/idea/help/creating-google-app-engine-project.html
My mistake was I removed [app]. It seems that if you create an App Engine backend module, you must keep a "fake" frontend module in the same project to keep Android Studio/gradle happy.
In earlier Android Studio versions it was possible to remove the frontend module without problems, but it seems Google has locked this somehow. It still works when I keep the fake frontend module.
--
Why I configured it this way? In my configuration, I have backend and frontend modules in different projects, and I have the backend project install libraries into local Maven, which I then pick up within my frontend project (with a team you would choose a local Maven server). This configuration has multiple advantages, for example that I can test backend/frontend on two screens simultaneously without switching back and forth all the time. Some companies may also want this configuration to keep their backend code separate and secure.
I am trying to run my gradle file with an already existing android project. The only error that I have with this application is Failed to find: com.getbase:floatingactionbutton:1.3.0. Below is my gradle file. Is there something that I need to change to get it to work?
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.google.android.gms:play-services:6.5.+'
compile 'com.getbase:floatingactionbutton:1.3.0'
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Please let me know if you require additional information. Thank you in advance!
According to a search on Maven Central at http://search.maven.org/#search%7Cga%7C1%7Cfloatingactionbutton that library exists, so I think the problem may be that you haven't added a repositories statement to your build script to let it resolve dependencies; the one you've got in the buildscript block is only to resolve build system plugins, not build dependencies. I know it's confusing. Add this block at the top level:
repositories {
mavenCentral()
}
I'm assuming also that you have a project with a flat directory structure and a single build.gradle file; when Android Studio creates projects via the wizard it uses a nested directory structure with multiple build.gradle files, and it normally adds boilerplate at the top-level build file so that you don't have to add this repositories block to each individual module's build file. If that's the case and that's in place, then this remedy won't work, so you'll have to dig deeper.
Make sure your "Global Gradle Settings" in Android Studio is NOT set for "Offline Work"
My Gradle was working up until I upgraded to Android Studio 0.8.5. Now the gradle build is broken with the error message:
Error:Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
(of class java.lang.String)
I am attaching the build.gradle file for reference:
buildscript {
repositories {
mavenCentral()
maven { url 'http://saturday06.github.io/gradle-android-scala-plugin/repository/snapshot' }
flatDir {
dirs 'libs/'
}
// flatDir {
// dirs '/Users/sto/workspace/robolectric-gradle-plugin.sonny/build/libs/'
// }
// flatDir {
// dirs '/Users/sto/workspace/gradle-android-scala-plugin/build/libs/'
// }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath 'jp.leafytree.gradle:gradle-android-scala-plugin:1.0-SNAPSHOT'
classpath 'org.robolectric:robolectric-gradle-plugin.sonny:0.12.1'
classpath "commons-io:commons-io:2.4"
classpath 'net.lingala.zip4j:zip4j:1.3.2'
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs/'
}
}
apply plugin: 'com.android.application'
apply plugin: 'android-scala'
apply plugin: 'robolectric'
robolectric {
include '**/*Test*.class'
}
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName '1.0'
// testInstrumentationRunner "android.test.InstrumentationTestRunner"
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}
packagingOptions {
exclude 'rootdoc.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'decoder.properties'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'LICENSE.txt'
}
sourceSets {
main {
java.srcDirs = ['src/main/gen-java', 'src/main/java', 'src/main/scala']
}
androidTest.setRoot('src/androidTest/')
androidTest {
java.srcDirs = ['src/androidTest/scala', 'src/androidTest/java']
}
}
android {
lintOptions {
abortOnError false
}
}
buildTypes {
debug {
runProguard true
proguardFile file('proguard-rules-debug.txt')
}
release {
runProguard true
proguardFile file('proguard-rules.txt')
}
}
}
dependencies {
compile project(':swiper')
compile 'org.scala-lang:scala-library:2.11.2'
compile 'org.json4s:json4s-native_2.11:3.2.10'
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.google.android:android:4.1.1.4'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
compile 'com.loopj.android:android-async-http:1.4.4'
compile 'com.edmodo:cropper:1.0.1'
compile 'de.hdodenhof:circleimageview:1.1.1'
compile 'org.fusesource.mqtt-client:mqtt-client:1.10'
compile 'log4j:log4j:1.2.17'
compile 'de.mindpipe.android:android-logging-log4j:1.0.3'
compile('org.apache.thrift:libthrift:0.9.1') {
transitive = false
}
compile 'ch.hsr:geohash:1.0.10'
compile 'org.slf4j:slf4j-android:1.7.7'
androidTestCompile('junit:junit:4.11') {
// exclude module: 'hamcrest-core'
}
androidTestCompile('org.robolectric:robolectric:2.3') {
exclude module: 'classworlds'
exclude module: 'commons-logging'
exclude module: 'httpclient'
exclude module: 'maven-artifact'
exclude module: 'maven-artifact-manager'
exclude module: 'maven-error-diagnostics'
exclude module: 'maven-model'
exclude module: 'maven-project'
exclude module: 'maven-settings'
exclude module: 'plexus-container-default'
exclude module: 'plexus-interpolation'
exclude module: 'plexus-utils'
exclude module: 'wagon-file'
exclude module: 'wagon-http-lightweight'
exclude module: 'wagon-provider-api'
}
}
I am still able to build using gradle (v1.12) from command line, but without using Studio I can't set my usual breakpoints for debug.
Update:
Turns out what was causing this issue for me (and likely for you, given the build file above) was the Scala plugin. There was a bug with the Scala plugin preventing Android Studio from importing Gradle projects. The fix for this has already been pushed live, so to get Android Studio working again you can either disable the Scala plugin or update it.
Open Settings/Preferences
Open the Plugins section on the left
Find the Scala plugin
Right click on the plugin and click Reload List of Plugins
Right click on the plugin again and click Update Plugin
This allowed me to do a Gradle sync and build from Android Studio again, I hope it helps for you!
Original answer below:
It looks like this is a bug with Android Studio. Hopefully it'll be fixed soon.
In the meantime, you can debug your application without launching it from Android Studio by attaching the debugger to a running process of the application. You can do this two ways.
Via the menus: Run -> Attach Debugger to Android Process
Pressing the button that is two to the right of the play/build button. It looks like a grey phone/rectangle with a little green bug in the bottom right
After you do this, a dialog will show up listing available applications to debug. Select your application and press OK. Your breakpoints should now work.
If you need to debug something that happens on app startup, you can tell Android to wait for a debugger when launching certain applications with the following steps:
On the phone open the Android Settings
Open the Developer Options
Make sure Wait for debugger is checked
Press Select debug app and choose your application
Then when you start your application, it'll wait for you to attach a debugger via one of the two methods mentioned above.
Hope this helps!
I have the CastSampleActivity set up with GoogleCastSdkAndroid, mediarouter and appcompact as dependencies, and I am able to build and launch on my phone. However no chromecast icon appears in the resulting app:
http://i.stack.imgur.com/KxMFJ.png (screenshot)
When I open activity_cast_sample.xml, I see the following:
The following classes could not be instantiated:
- android.support.v7.app.MediaRouteButton (Open Class, Show Error Log)
Which leads to a stack trace:
java.lang.NullPointerException
at com.android.layoutlib.bridge.android.BridgeContext.resolveThemeAttribute(BridgeContext.java:278)
at android.content.res.Resources_Theme_Delegate.resolveAttribute(Resources_Theme_Delegate.java:64)
at android.content.res.Resources$Theme.resolveAttribute(Resources.java:1426)
at android.support.v7.app.MediaRouterThemeHelper.isLightTheme(MediaRouterThemeHelper.java:51)
at android.support.v7.app.MediaRouterThemeHelper.createThemedContext(MediaRouterThemeHelper.java:30)
at android.support.v7.app.MediaRouteButton.<init>(MediaRouteButton.java:121)
at android.support.v7.app.MediaRouteButton.<init>(MediaRouteButton.java:117)
Anyone know what's going on?
This is a completely unmodified CastSampleActivity from GitHub, except for my app_id of course. I am able to cast from Youtube, Netflix, etc...
The instantiation error is normal.
Did you change the manifest or the theme settings in any way?
I had this problem too, it's incorrect project setup. Are you using Gradle? If you are, then have your build.gradle file somewhat like: (remember to put the googlecastsdk library in your libs folder)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.1+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
dependencies {
compile "com.android.support:appcompat-v7:18.0.+"
compile "com.android.support:mediarouter-v7:18.0.+"
compile files('libs/GoogleCastSdkAndroid.jar')
}