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

Sunday, December 20, 2015

Solving Gradle DSL method not found : 'android()'


Getting "Gradle DSL method not found : 'android()" error, well then you are at right place to solve the things :)


Solution:
  • Open the project top level 'build.gradle' file
  • Remove the below configuration  android() method 

// Delete these lines from project top level 'build.gradle' file
android {
 compileSdkVersion 23
 buildToolsVersion '22.0.1'
}

  • Save the changes and re-compile 

Saturday, April 4, 2015

An error occurred while resigning the app 'selendroid-test-app-0.15.0.apk'

         
                     An error occurred while resigning the app 'selendroid-test-app-0.15.0.apk'


If you got the same error message while trying to start the Selendoid server with your apk file, try the below to fix it :

Solution : 

  1.  Check JAVA_HOME is set properly
    • Set System variable with name "JAVA_HOME"  with value set to Java jdk like "C:\Program Files\Java\jdk1.8.0_40\"
  2. Check ANDROID_HOME is set properly
    • Set System variable with name "ANDROID_HOME"  with value set to Android Sdk like "C:\Users\lalit\AppData\Local\Android\sdk\"


Still after setting the above variables correctly, if you see any error try to sign your app manually using below command

C:\Program Files\Java\jdk1.8.0_40\bin> jarsigner.exe -sigalg MD5withRSA -digestalg SHA1 -signedjar < apk file path >  -storepass android -keystore <keystore location> < apk file path >  androiddebugkey

Example:

C:\Program Files\Java\jdk1.8.0_40\bin > jarsigner.exe -sigalg MD5withRSA -digestalg SHA1 -signedjar C:\Users\lalit\Downloads\selendroid-test-app-0.15.0.apk -storepass android -keystore C:\Users\lalit\.android\debug.keystore C:\Users\lalit\Downloads\selendroid-test-app-0.15.0.apk androiddebugkey

If it fails and throws error like  jarsigner: unable to open jar file

Solution : 

  1. Try to rename your *.apk file to *.zip
  2. Open the zip file and verify its opened successfully, and if it does not then its currupt apk file :( and need to be changed :)

Sunday, January 11, 2015

Android Json tutorial : Saving custom class object as JSONObject and JSONArray on Parse

Android JSONObject and JSONArray allows you to save your custom class values on the Parse.com as a json string.
                  Suppose you would like to save your custom class values in a single Parse.com class column, you can just convert your class parameter values in JSONObject and then can save in a column on Parse.com.

Saving JSONObject on Parse
// Create a Parse object for the table under which you like to add your json object in a column.
ParseObject parseObject = new ParseObject("MainTable");

// Add your JSONObject
parseObject.put("myCustomClass",new JSONObject().put("key","value"));
// Tip : Here you can add all of your custom class variable as key value pair in JSONObject

// Save the Parse object
parseObject.saveInBackground();

Saving JSONArray on Parse [ If you like to save an array of custom class instances]
// Create a Parse object for the table under which you like to add your json object in a column.
ParseObject parseObject = new ParseObject("MainTable");

// Add your JSONArray
JSONArray jsonArray = new JSONArray("myCustomClassArray");
jsonArray.put(new JSONObject().put("key1","value1"));
jsonArray.put(new JSONObject().put("key2","value2"));
// Tip : Here you can add all of your custom class variable as key value pair in JSONObject

// Save the Parse object
parseObject.saveInBackground();

Friday, January 2, 2015

ParseUser.logout() doesn't logs user out

Recently working on a android app integrated with Parse and Facebook, i observed the issue that just calling the ParseUser.logout() does not clear the authenticated user token and logs in the user again on clicking on 'Log in as Facebook' even if user have logged out from the Facebook app also.


goggled the solution, but found this is as Design :(


So, still if you like to invalidate the facebook authentication token on ParseUser.logout(), you can do by adding a few lines of code shown below.


#################Code Snippet#####################

// Logout already logged in user from your android app.

ParseUser.logout();


// Check if user is logged in Facebook android app or not. If not clear the token information  explicitly.

 com.facebook.Session facebookSession= com.facebook.Session.getActiveSession();
        if (facebookSession== null) {
            facebookSession= new com.facebook.Session(this);
            com.facebook.Session.setActiveSession(facebookSession);
        }
        facebookSession.closeAndClearTokenInformation();

#################Code Snippet#####################

Now, when you click on 'Log in with Facebook', user will be taken to login screen and there you can then log in to your app as different user :)


Monday, December 29, 2014

Facebook Android Sdk : Serialize GraphUser object


If you check at the Facebook sdk GraphUser object documentation , it does not implements the java.io.Serializable as a result of which you can pass the GraphUser object through activities.


Though if you like to pass GraphUser to other activities, you can do it by saving GraphUser json string in a String instance and then pass it,


// Save GraphUser json information in String instance and pass to another activity using intent
List<GraphUser> selectedUsers = friendPickerFragment.getSelection();
List<GraphUser> selectedUsersJson = new ArrayList<String>();
for (GraphUser graphUser : selectedUsers) {
selectedUsersJson.add(graphUser.getInnerJSONObject().toString());
}


// Re-initialize the GraphUser from the saved graph user json from the intent
List<GraphUser> selectedUsers = new ArrayList<GraphUser>();
for (String graphUserJson : selectedUsersJson) {
selectedUsers .add(GraphObject.Factory.create(new JSONObject(graphUserJson),GraphUser.class));
}


Happy Serializing :)

Saturday, December 6, 2014

Download Android SDK offline

Many of you interested in Android development or automation, must have downloaded Android SDK installer and have noticed once you install the SDK on your machine, you still need to download some more file using the Android SDK Manager like :

Android SDK Tools
Android Platform Tools
Android API's

In some case you may not have the fast internet connection/bandwidth to download this much stuff.( Same with me :D ). So, here is the solution i am sharing with you guys how you can download with stuff from an high internet connection machine and then cut and paste to your development machine :)
  1. Navigate to the link https://dl-ssl.google.com/android/repository/repository-10.xml in browser. [ Note this is the last updated link at the time of writing this post.In future you will need to check the latest page by +1 increment to digit shown in url. Example next updated version should have 'respository-10.xml' in end ]
  2.  Search for the sdk-tools/platform-tools/other stuff in the page like:
    1.   For example to download the android sdk api 21,search for "android-21". You will see entry in xml like "android-21_r01.zip"
    2. Copy the entry and append to url 'http://dl-ssl.google.com/android/repository/'
    3. Your download url will be like http://dl-ssl.google.com/android/repository/android-21_r01.zip
[ Similarly you can download the other stuff zip files as mentioned in above steps ]

Once you have downloaded, you just copy the zip file to your development machine.Extract the files and place under <android-sdk-path>/<respective-folder-for-tools/other-stuff>. 

You can check the placed files are correct,by opening the ANDROID SDK MANAGER and check the Status of downloaded tools is shown as 'INSTALLED'
:) :)



sdk tools/platform tools/API's download links for your reference  [ latest as of post writing ]

Leave your question in case of any issues :) 

Thursday, July 10, 2014

Hide photos videos on your Android mobile without any software


So, everybody may have got the issue with hiding personal videos or images on their mobile phones. And also there are lot of software to serve the purpose but the problem with them is that either good ones are paid or not that good.

Here i will show you the way to hide any files mainly images/videos from your android gallery.

1. On your Android mobile phone, first download and install a File manager if you does not have already.  Here, i have used the 'ES File Explorer' which you can download freely from the Google play.


2. Open the File Explorer -> Go to its Settings ->  Set 'Show Hidden Files' to 'ON'

3. Create a new folder in File Manager with name ".hide". You can see that created folder is faded as compared to other folders with does not start with a "."

                                 [ Here you can pick any name but is should start with a "." ]

3.Move you all the files images/videos to ".hide" folder, Go and check in gallery now they are not visible there : ) 

4.  Now, if you want to view the hidden stuff yourself then you can:
  1. View directly by going to hidden folder from the File Explorer.
  2. Or can rename the hidden folder by removing the "." from the front it will be again visible in Gallery.    Again then you can add "." in folder name to hide it again :)


AWS Certified Solutions Architect Associate - AWS Introduction - Questions

All the Best !!! Show Result !! Try Again !! ×