Last active
January 13, 2017 03:13
-
-
Save shts/98c4014a19eedb1795ed to your computer and use it in GitHub Desktop.
gradle.propertiesに定義した値をJavaソースから参照する ref: http://qiita.com/shts/items/d94834437b22712415c5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BuildConfig.java を公開しないようにするため | |
/build | |
# gradle.properties を公開しないようにするため | |
gradle.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildTypes { | |
debug { | |
buildConfigField "String", "PARSE_API_ID", "\"${project.property("parseApiId")}\"" | |
buildConfigField "String", "PARSE_API_KEY", "\"${project.property("parseApiKey")}\"" | |
} | |
release { | |
buildConfigField "String", "PARSE_API_ID", "\"${project.property("parseApiId")}\"" | |
buildConfigField "String", "PARSE_API_KEY", "\"${project.property("parseApiKey")}\"" | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class BuildConfig { | |
// Fields from build type: debug | |
public static final String PARSE_API_ID = "xxxxxxxxxxxxxxxxxxxxx"; | |
public static final String PARSE_API_KEY = "xxxxxxxxxxxxxxxxxxxxx"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildConfigField "String", "PARSE_API_ID", "\"${project.property("parseApiId")}\"" | |
buildConfigField "String", "PARSE_API_KEY", "\"${project.property("parseApiKey")}\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parseApiId=xxxxxxxxxxxxxxxxxxxxx | |
parseApiKey=xxxxxxxxxxxxxxxxxxxxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyApplication extends Application { | |
public MyApplication() { | |
super(); | |
} | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
Parse.initialize(this, BuildConfig.PARSE_API_ID, BuildConfig.PARSE_API_KEY); | |
ParseInstallation.getCurrentInstallation().saveInBackground(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment