RSS

Category Archives: Android

‘com.github.dcendents.android-maven’ not found, the solution


Recently, I build some open source Android libraries, and when building the project, below error occurred:

Error:(2, 0) Plugin with id ‘com.github.dcendents.android-maven’ not found.

Quick Solution:

install Yarn, everything works!

Mac: brew install yarn
Windows: refer to this link.

 

A less elegant solution is to manually change the top level build.gradle:

From

dependencies {
classpath ‘com.android.tools.build:gradle:2.2.2’
}

To –>

dependencies {
classpath ‘com.android.tools.build:gradle:2.2.2’
classpath com.github.dcendents:android-maven-gradle-plugin:1.5  //Add this
classpath com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3      //Add this

}

Rebuild. It should work. But this is tedious, for every project (e.g. react-native), you repeat doing so?  Emmmmmm!

Now try to create a new react-native project using:

react-native init ProjectName

Run the project:

react-native run-android  // or
react-native run-ios

It compiles and works! Happy coding.

Advertisements
 
2 Comments

Posted by on April 18, 2017 in Android

 

Tags: , , , , , , , , , , , ,

Android Automated UI Testing with Expresso (I)


I have been trying to write a few articles on Android automated UI testing for a long time, ever since my last job when we started experimenting using Expresso in our commercial Android App.

This article outlines the simplest UI testing with Expresso, with step-by-step snapshots for beginners to walk through.

simpleuitesting_activities

Read the rest of this entry »

 
Leave a comment

Posted by on November 25, 2016 in Android

 

Tags: , , , ,

Step-by-Step guide for developing Android Plugin for Unity3D (II)


In previous blog, I have covered how to handshake Native Android code with Unity3D. The example shown therein is pretty simple: how to call a java function in C#!

In this blog, I am trying to step one more stride further: to create and use an Android View in Unity3D. The example shown here is an Android ImageView, however, this approach is generally applicable to all kinds of Android Views, ViewGroups and custom views.

imageAn Android ImageView

imageUse Android ImageView in Unity3D

Read the rest of this entry »

 
10 Comments

Posted by on August 10, 2016 in Android, Programming, Unity 3d

 

Tags: , , , , , , ,

Android: get active, current or foreground Activity


In our recent Android App development, we developed many static utility functions, which needs a Context as the argument:

public static void func1(Context context, …)
public static void func2(Context context, …)
public static void func3(Context context, …)

public static void funcN(Context context, …)

This is very cumbersome. We would like to refactor these utility functions into functions without the context argument/ A natural idea to pass in the application context at the very beginning, e.g. Application.onCreate() function, but not in all cases, can we use the application context. For instance, when you create a dialog or toast window, we need to use Activity as the context. So here comes the function that works:

image

Visit this gist to get the source code.

 
Leave a comment

Posted by on July 13, 2016 in Android, Programming

 

Tags: , , , , , , ,

Android: automatic set or update versionName from versionCode


In Android, version name and version code serve for different purposes, as is found in Android documentation here:

android:versionCode

An internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute. The value must be set as an integer, such as “100”. You can define it however you want, as long as each successive version has a higher number. […]

android:versionName

The version name shown to users. This attribute can be set as a raw string or as a reference to a string resource. The string has no other purpose than to be displayed to users. The versionCode attribute holds the significant version number used internally.

In practice, it is often the case that the version name simply maps version code in specific ways, e.g.

2016 (version code)  –>  v2.0.1.6 (version name)

Read the rest of this entry »

 
Leave a comment

Posted by on June 13, 2016 in Android, Programming

 

Tags: , , , , , , , ,

Android: Handle Custom protocol Urls


You might ever found custom protocol urls like below:

    example://SomeHostPrefix/?UserName=abcdef&SessionId=12345

When you copy this custom protocol url in your mobile browser, you will find that an Android App is activated, rather than a new web page. How to implement such functions in your own Android App? This article offers a walk through example to do so.

CustomUrl

Read the rest of this entry »

 
Leave a comment

Posted by on May 13, 2016 in Android, Programming

 

Tags: , , , ,

Install Statistics plugin for AndroidStudio: crash and troubleshooting


Statistic is a very powerful plugin for IntelliJ IDEA, which is very useful to show files sorted by their extension along with size, line count LOC etc.

However, if you install this into the latest version of Android Studio, you are most likely to get the below error message:

Plugin ‘Statistic’ failed to initialize and will be disabled. Please restart Android Studio. com.intellij.diagnostic.PluginException: com/jpower8/idea/plugin/statictic/StatisticApplicationComponent : Unsupported major.minor version 51.0 [Plugin: Statistic] at com.intellij.ide.plugins.cl.PluginClassLoader.loadClassInsideSelf(PluginClassLoader.java:130).

To troubleshoot this problem, follow below procedures:

Select Android Studio in Applications:

image

Right click Android Studio > Show Package Contents

image

Open the Info.plist

image

Change the JVMVersion from 1.6* or whatever –> 1.8

image

Of course you have to install JDK 1.8! Restart Android Studio and enjoy!

image

 
Leave a comment

Posted by on May 4, 2016 in Android

 

Tags: , , , , , , , ,