Header Ads

My experience of learning Android development

Experience, Android, Development
Your life is short , don't waste your time with emulator.

After working on android development for a few year , i have collected something in my pocket , some painful experience . And today i want to share it , make a check list for myself.

Project structure

Android_structure ├─ com.example │ ├─ activities │ ├─ adapters │ ├─ fragments │ ├─ project │ ├─ interfaces │ ├─ models │ ├─ navigates │ ├─ networks │ ├─ notifications │ ├─ utils │ └─ views


project: project name. Store all thing about "project" like Config.java, Application.java...
models: Working with preference,SQLlite..
networks: Picaso. Volley, OKHttp
utils: Something like StorageUtil.java, ImageUtil.java...
views: Store all custom view.

DebugLog.java Instead of Log.java

//Normal way
if (Config.IS_DEBUG) { Log.i(String, String); }

//Better version
public class DebugLog { public static void i(String tag, String msg) { if (Config.IS_DEBUG) { Log.i(tag, msg); } } }

Gradle configuration

Passwords. In your app's build.gradle you will need to define the signingConfigs for the release build. Here is what you should avoid:
Don't do this. This would appear in the version control system.
signingConfigs {
    release {
        storeFile file("myapp.keystore")
        storePassword "password123"
        keyAlias "thekey"
        keyPassword "password789"
    }
}
Instead, make a gradle.properties file which should not be added to the version control system:
KEYSTORE_PASSWORD=password123
KEY_PASSWORD=password789
That file is automatically imported by Gradle, so you can use it in build.gradle as such:
signingConfigs {
    release {
        try {
            storeFile file("myapp.keystore")
            storePassword KEYSTORE_PASSWORD
            keyAlias "thekey"
            keyPassword KEY_PASSWORD
        }
        catch (ex) {
            throw new InvalidUserDataException("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.")
        }
    }
}

Update....

No comments:

Powered by Blogger.