Tuesday, 24 January 2017

Gradle sync failed: The android gradle plugin version 2.3.0-beta1 is too old, please update to the latest version
   To override this check from the command line please set the ANDROID_DAILY_OVERRIDE environment variable to "bcfc63e5d0a4f1655d523dcea7fe470ca02f0690"
            Consult IDE log for more details (Help | Show Log)



You need to update the version of the gradle tools you are building with. This can be found inside the dependencies section of your build.gradle. You have 3 options you can update to:
The latest stable version referenced in the release channel as of 6th December, 2016 is
classpath 'com.android.tools.build:gradle:2.2.3'
Or the latest beta version via dev channel / beta channel as of 11th November, 2016 is
classpath 'com.android.tools.build:gradle:2.3.0-beta1'
And the latest alpha version from the canary channel as of 21st November, 2016 gives you the option to use
classpath 'com.android.tools.build:gradle:2.3.0-alpha3'
Updating requires you to also upgrade the gradle wrapper. As of 3rd January '17, the newest is:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
On android studio you can find your wrapper by changing to the project view and looking in gradle/wrapper/gradle-wrapper.properties





Thursday, 11 June 2015

Passing Extra value to an activity that is already running in foreground


- . If the activity is already running the extra value passed to the activity is not recognized. since onCreate has no effect and its state is over.Adding OnNewIntent solved my problem by folloowing below link

 @http://www.helloandroid.com/tutorials/communicating-between-running-activities

Communicating between running activities

Starting a new activity from another and passing some data to it is a simple and basic thing in android. But if you want an already running activity to come to foreground, and pass data to it, it can be a bit tricky.
First of all by default if you call an activity with an intent, a new istance of that activity will be created and displayed, even if another instance is already running. To avoid this the activity must be flagged that, it should not be instantiated multiple times. To achieve this we will set the launchMode of the activity to singleTask in the AndroidManifest.xml
  1. <activity android:name="Activity1" android:launchMode="singleTask"android:label="@string/app_name">
This way when we call this activity using an intent, if there is an existing instance, the system will route the request to it. Hoever the onCreate method, where we usually process the passed extraData, will not run this time.
As its name shows it runs when the activity is created and this time it already exists, so the methodcalled onNewIntent() will be called.
  1. protected void onNewIntent(Intent intent) {
  2.   super.onNewIntent(intent);
  3.   setIntent(intent);//must store the new intent unless getIntent() will return the old one
  4.   processExtraData();
  5. }
Do not forget that we can receive data in the normal way in onCreate, when the activity is first created, and since the system can easily kill activities in the backround, if this happens, the onCreate method will be called instead of onNewIntent.
So an elegant solution may call the same function to process extraData from intent from onCreate and onNewIntent.
  1. public void onCreate(Bundle savedInstanceState) {
  2.   super.onCreate(savedInstanceState);
  3.   setContentView(R.layout.main);
  4.   processExtraData();
  5. }
  6. protected void onNewIntent(Intent intent) {
  7.   super.onNewIntent(intent);
  8.   setIntent(intent);//must store the new intent unless getIntent() will return the old one
  9.   processExtraData()
  10. }
  11. private void processExtraData(){
  12.   Intent intent = getIntent();
  13.   //use the data received here
  14. }

Sunday, 23 November 2014

Android java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

You have put 3rd party library in library folder and reference them. Go to Properties/ Java Build Path/ Libraries/ Add External JARs.
Check the Jar files in the Properties/ Java Build Path/ Order and Export

Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 5108 (Thread-3126)

I am trying to open my application on clicking on notification. The app gets closed when i click on notification while it is running ie in foreground it shows "Unfortunately, App has stopped". upon clicking notification second time the app open perfectly. It throws the below error on clicking notification first time. Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 5108 (Thread-3126)

Adding android:launchMode="singleInstance" in manifest solved the problem. The issue is whenever i am trying to open the app by clicking notification the object is re created

you can have detailed log error at
  
http://stackoverflow.com/questions/26966374/opening-application-on-clicking-notification-shows-unfortunately-app-has-stopped 

Wednesday, 10 September 2014

Google-play-services_lib Unable to resolve target 'android-9

Problem :
   When trying to import   Google-play-services_lib to eclipse get the following error.
 
                     Google-play-services_lib Unable to resolve target 'android-9
Solution:
     Open the SDK Manager, click obsolete (so API 9 shows up), and grab API 9.I. Install API 9 packages.

Monday, 8 September 2014

Unexpected namespace prefix "xmlns" found for tag fragment

Problem:
     <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/spr_place_type"
        class="com.google.android.gms.maps.SupportMapFragment" />   

Solution:

Remove xmlns:android="http://schemas.android.com/apk/res/android" from the <fragment> element, and consider moving xmlns:map="http://schemas.android.com/apk/res-auto" from the <fragment> element to the root element.
For example, this is valid:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:id="@+id/foo"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"
        map:mapType="satellite"/>

</RelativeLayout>

Saturday, 30 August 2014

android dialogfragment cannot be resolved to a type

solution:
Right click on your project folder -> Build path -> Configure build path -> Add External Jars(From libraries tab) -> select "android-support-v4.jar" file.
(It'll be located in Android SDK folder here is generic path "android-sdk\extras\android\support\v4").