Showing posts with label Android Studio. Show all posts
Showing posts with label Android Studio. Show all posts

Monday, 18 April 2016

Gradle Issue : Process finished with non-zero exit value 2

10:20:00 Posted by Kumanan , ,
Click here

This issue is quite possibly due to exceeding the 65K methods dex limit imposed by Android. This problem can be solved either by cleaning the project, and removing some unused libraries and methods from dependencies in build.gradle, OR by adding multidex support.

So, If you have to keep libraries and methods, then you can enable multi dex support by declaring it in the gradle config.

defaultConfig {        
    // Enabling multidex support.
    multiDexEnabled true
}

Gradle Issue : Manifest merger failed when importing library project

10:19:00 Posted by Kumanan , ,
It seems to be the fault of the mainfest Merger tool for gradle.

Solved it by adding to my manifest tag xmlns:tools="http://schemas.android.com/tools"

Then added tools:replace="android:icon,android:theme" to the application tag

This tells the merger to use my manifest icon and theme and not of other libraries


Example:-

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"  // add tools line here 
    package="yourpackage">


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:replace="android:icon"> ///add this line 

.....

</application>

</manifest>

Hope it helps thanks

Wednesday, 26 August 2015

Lombok error in Android Studio

18:36:00 Posted by Kumanan ,
javax.annotation does not exist error


Solution :-

If you're facing same issue in Android Studio using gradle - add following line to build.gradle:

provided 'org.glassfish:javax.annotation:10.0-b28'

Error type 3 in Android Studio

18:32:00 Posted by Kumanan ,
Activity class {} does not exist in Android Studio

I faced a similar problem after refactoring.
This is what i did to resolve this issue:

Cleaned the Project
Deleted the Build directory
Restarted Android Studio
Rebuild the Project
Run
And everything worked fine!
I think the key is to restart your IDE.

Hope this helps you or anyone else!

Monday, 30 March 2015

Add Google Play Services to Your Project in Android Studio

12:10:00 Posted by Kumanan ,
Step 1:-
Open the build.gradle file inside your application module directory.

Note: Android Studio projects contain a top-level build.gradle file and a build.gradle file for each module. Be sure to edit the file for your application module.

Step 2:-
Add a new build rule under dependencies for the latest version of play-services. For example:

apply plugin: 'com.android.application'
...

dependencies {
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:7.0.0'
}

Be sure you update this version number each time Google Play services is updated.

Note: If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them.

Step 3:-
Save the changes and click Sync Project with Gradle Files.

Step 4:-
Open your app's manifest file and add the following tag as a child of the <application> element:

<meta-data android:name="com.google.android.gms.version"
           android:value="@integer/google_play_services_version" />

You can now begin developing features with the Google Play services APIs.

Tuesday, 17 February 2015

android duplicate files copied in apk meta-inf/notice.txt

12:49:00 Posted by Kumanan ,

The DSL to exclude files is:

android {
    packagingOptions {
        exclude 'META-INF/NOTICE.txt'
    }
}

You can add as many exclude statement as you want. The value is the archive path. No wildcard or glob support yet.

Note:-
You can add many statement like below.

packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

Android Studio - gradle dsl method not found packagingoptions

12:30:00 Posted by Kumanan ,
Check the bundle.gradle file whether  it contains the following code snippet.

packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

Complete bundle.gradle file looks like the below snippet.


apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.rabbitmq:rabbitmq-client:1.3.0'

}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.kums.thingsworked"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}


Monday, 2 February 2015

How to install Lombok in android studio

17:45:00 Posted by Kumanan
In addition to setting up your gradle project correctly, you need to add the Lombok IntelliJ plugin to add lombok support to Android Studio:

Go to File > Settings > Plugins
Click on Browse repositories...
Search for Lombok Plugin
Click on Install plugin
Restart Android Studio

Tuesday, 13 January 2015

Android Studio Shortcuts - Needful

12:25:00 Posted by Kumanan ,

Go to class CTRL + N
Go to file  CTRL + Shift + N
Navigate open tabs ALT + Left-Arrow; ALT + Right-Arrow
Look up recent files CTRL + E
Go to line CTRL + G
Navigate to last edit location CTRL + SHIFT + BACKSPACE
Go to declaration CTRL + B
Go to implementation CTRL + ALT + B
Go to source F4
Go to super Class CTRL + U
Show Call hierarchy CTRL + ALT + H
Search in path/project CTRL + SHIFT + F


Programming Shortcuts:-

Reformat code CTRL + ALT + L
Optimize imports CTRL + ALT + O
Code Completion CTRL + SPACE
Issue quick fix ALT + ENTER
Surround code block CTRL + ALT + T
Rename and Refractor Shift + F6
Line Comment or Uncomment CTRL + /
Block Comment or Uncomment CTRL + SHIFT + /
Go to previous/next method ALT + UP/DOWN
Show parameters for method CTRL + P
Quick documentation lookup CTRL + Q
Delete a line CTRL + Y
View declaration in layout CTRL + B
To find Usage of selected Text ALT + F7 or goto Edit -> Find -> Find Usages
To check unused res files in android studio - Control + Alt + Shift + i and type "Unused resources"