If you encounter…

“Gradle Version 2.10 is required.” Error

Solution: Set Use default gradle wrapper and edit Project\gradle\wrapper\gradle-wrapper.properties files field distributionUrl like this:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

Trying to add adb to PATH variable OSX

Solution: Edit the ~/.bash_profile like this:

export PATH="/Users/elsalin/Library/Android/sdk/platform-tools:$PATH"
export PATH="/Users/elsalin/Library/Android/sdk/tools:$PATH"

emulator: ERROR: Unfortunately, there’s an incompatibility between HAXM hypervisor and VirtualBox 4.3.30+ which doesn’t allow multiple hypervisors to co-exist. It is being actively worked on; you can find out more about the issue at http://b.android.com/197915 (Android) and https://www.virtualbox.org/ticket/14294 (VirtualBox)

Solution: In my case I was running a docker vm at same time, when stopped it android emulator launched successful.

java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String android.content.Intent.getStringExtra(java.lang.String)’ on a null object reference

Solution: getStringExtra() should wrap under onCreate(), not out above onCreate(). The upper place where you write is executed when the constructor of the activity is invoked, at this point, the Intent obeject does not exist yet. Android does a lot of things after the constructor was invoked and then invokes onCreate.

public class DisplayMessageActivity extends AppCompatActivity {

// DO NOT PUT HERE
//    Intent intent = getIntent();
//    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_display_message);

        Intent intent = getIntent();
        String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

W/com.google.zxing.client.android.camera.open.OpenCameraInterface: No cameras!

Solution: You should enable the AVD’s camera. In Android Studio, go to AVD Manager, click on edit (pencil) button in Actions. After that, in next appearing window, click on Advance settings, and then scroll down and in Camera options, select webcam for front and back.

Unexpected error initializing camera java.lang.RuntimeException: Fail to connect to camera service

Solution: Getting camera error in Zxing barcode application, for Android 6+, because of the “permission” issue. If you got the message “Sorry, the camera encountered a problem. You may need to restart the device.”, go to Settings - Apps - find “your app name” - select Permissions and switch on “Camera”.

Getting Error “Gradle DSL method not found: ‘compile()’” when Syncing Build.Gradle

Solution: Dependencies should be put into the individual module’s build.gradle files rather than at the top most level build.gradle file. In my case, that means the dependency should be added to the app module’s build.gradle file.

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile files('libs/magellan.jar')
    compile 'com.android.support:appcompat-v7:22.2.1'
}

No resource found that matches the given name ‘Theme.AppCompat.Light.DarkActionBar’.

Solution: AppCompat is a library project. You need to reference the library project in your android project. Check the topic Adding libraries with resources.

Error retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23

Solution: Your compile SDK version must match the support library’s major version. Since you are using version 23 of the support library, you need to compile against version 23 of the Android SDK. Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.

change

dependencies {
    compile 'com.android.support:appcompat-v7:23.4.0'
}

back to

dependencies {
    compile 'com.android.support:appcompat-v7:22.2.1'
}

[java.lang.NullPointerException: Attempt to get length of null array][R10]

import net.magellan.BaseRequest;

public void onError(BaseRequest req){

    Log.v("Worker", new String(req.getResponseData())); // ---> here got a null pointer
}

Solution: The problem is because getResponseData() return null.

I/Choreographer: Skipped 48 frames! The application may be doing too much work on its main thread.

Solution: ongoing…

[java.lang.IllegalStateException: Cannot execute task: the task has already been executed (a task can be executed only once)][]

Solution: When using AsyncTask, you cannot call execute(); twice. But if you new an AsyncTask everytime, you should consider how to claim your AsyncTask. Afterall, you have to stop all the AsyncTasks in the onStop() of activity.

Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 4438 (Timer-20)

Solution: This is memory related error. You may have a memory leak or out of memory in your device. Check if your stop thread before it goes unclaimed.

Android “Only the original thread that created a view hierarchy can touch its views.”

Solution: You have to move the portion of task that updates the ui onto the main thread. To do this, create a Handler in the UI thread and then use it to post or send a message from your other thread to update the UI.

Runnable runnable = new Runnable() {
    @Override
    public void run() {

        //update ui
        progressBar.setVisibility(View.GONE);
        scrollView.setVisibility(View.GONE);
    }
};

Handler handler = new Handler(Looper.getMainLooper());
handler.post(runnable);