Skip to content

Commit

Permalink
fix(android): fix android build
Browse files Browse the repository at this point in the history
  • Loading branch information
gfanton committed Dec 10, 2018
1 parent f75b1d0 commit eea3c58
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 32 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Expand Up @@ -265,10 +265,11 @@ jobs:
- run:
name: set version
working_directory: ~/go/src/berty.tech/client/react-native
command: make version
command: make version.android

- run:
name: build app
working_directory: ~/go/src/berty.tech/client/react-native
command: /tmp/retry -m 3 make fastlane.android.build

- store_artifacts:
Expand Down Expand Up @@ -355,7 +356,7 @@ jobs:
- run:
name: set version
working_directory: ~/go/src/berty.tech/client/react-native
command: make version
command: make version.ios

- run:
name: install fsevents
Expand Down
13 changes: 9 additions & 4 deletions client/react-native/Makefile
Expand Up @@ -243,10 +243,15 @@ webapp.rm: webapp.stop
.PHONY: version
version:
mkdir -p $(BUILD)
echo "ios:$(IOS_VERSION)\nandroid:$(ANDROID_VERSION)\n" > $(BUILD)/version

plutil -replace CFBundleShortVersionString -string $(IOS_VERSION) $(IOS)/Berty/Info.plist
.PHONY: version.android
version.android: version
bundle exec fastlane run increment_version_code version_code:$(ANDROID_VERSION) gradle_file_path:$(ANDROID)/app/build.gradle
echo "ios:$(IOS_VERSION)\nandroid:$(ANDROID_VERSION)\n" > $(BUILD)/version

.PHONY: version.ios
version.ios: version
plutil -replace CFBundleShortVersionString -string $(IOS_VERSION) $(IOS)/Berty/Info.plist

fastlane.match.development:
time bundle exec fastlane run match type:development
Expand Down Expand Up @@ -289,11 +294,11 @@ fastlane.ios.build:
fastlane.android.build:
mkdir -p $(ANDROID_BUILD) /tmp/android/keystore

ORG_GRADLE_PROJECT_BERTY_APK_OUTPUT_DIR="$(PWD)/$(ANDROID_BUILD)" \
ORG_GRADLE_PROJECT_BERTY_APK_OUTPUT_DIR="$(shell realpath '$(ANDROID_BUILD)')" \
FL_GRADLE_PROJECT_DIR=android \
FL_BUILD_TYPE=release \
FL_GRADLE_TASK=assembleReleaseAndPublish \
time bundle exec fastlane run gradle --verbose
bundle exec fastlane run gradle --verbose

# test if apk has been correctly exported
test -f $(ANDROID_BUILD)/*.apk
Expand Down
10 changes: 7 additions & 3 deletions client/react-native/android/app/build.gradle
Expand Up @@ -95,7 +95,7 @@ def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion '28.0.3'
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
applicationId "chat.berty"
Expand All @@ -110,15 +110,19 @@ android {
signingConfigs {
release {
if (project.hasProperty('BERTY_RELEASE_STORE_RAW_B64')) {
print "decoding base64 keystore... "
def rawFile = BERTY_RELEASE_STORE_RAW_B64.decodeBase64()
println "SUCCESS"
def file = File.createTempFile("berty", "keystore", null)
println "generating keystore into ${file.getAbsolutePath()}"
print "generating keystore into ${file.getAbsolutePath()}... "
def stream = new FileOutputStream(file.getAbsolutePath())
stream.write(rawFile)
project.setProperty('BERTY_RELEASE_STORE_FILE', file.getAbsolutePath())
project.ext { BERTY_RELEASE_STORE_FILE = file.getAbsolutePath() }
println "SUCCESS"
}

if (project.hasProperty('BERTY_RELEASE_STORE_FILE')) {
println "app will be signed using ${BERTY_RELEASE_STORE_FILE}"
storeFile file(BERTY_RELEASE_STORE_FILE)
storePassword BERTY_RELEASE_STORE_PASSWORD
keyAlias BERTY_RELEASE_KEY_ALIAS
Expand Down
11 changes: 4 additions & 7 deletions client/react-native/android/app/publish.gradle
Expand Up @@ -11,15 +11,12 @@ android {
&& output.outputFile.name.endsWith('.apk')) {

def task = project.tasks.create("copy${variant.name}Apk", Copy)
task.doFirst {
println "Creating ${rootProject.name} (${versionName}.${versionCode}) from ${project.name}-${variant.name}.apk"
}

def outputFile = output.outputFile
output.outputFileName = "${rootProject.name}.apk"


def fileName = outputFile.name.replace(project.name + "-${variant.name}.apk", "${rootProject.name}.apk")
output.outputFileName = new File(fileName)
task.doFirst {
println "Creating ${BERTY_APK_OUTPUT_DIR}/${output.outputFileName}.apk (${versionName}.${versionCode})"
}

task.from(output.outputFile)
task.into(BERTY_APK_OUTPUT_DIR)
Expand Down
Expand Up @@ -40,22 +40,15 @@ public boolean getUseDeveloperSupport() {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage(),
new SvgPackage(),
new ReactNativeRestartPackage(),
new RNNetworkInfoPackage(),
new ImagePickerPackage(),
new ReactNativeExceptionHandlerPackage(),
new RNCameraPackage(),
new RNCameraPackage(),
new SvgPackage(),
new ReactNativeRestartPackage(),
new ReactNativeExceptionHandlerPackage(),
new CorePackage(),
new VectorIconsPackage(),
new ImagePickerPackage(),
new MainReactPackage(),
new RNCameraPackage(),
new RNNetworkInfoPackage(),
new ImagePickerPackage()
new ReactNativeExceptionHandlerPackage(),
new ReactNativeRestartPackage(),
new SvgPackage(),
new VectorIconsPackage()
);
}

Expand Down
15 changes: 13 additions & 2 deletions client/react-native/android/build.gradle
Expand Up @@ -2,9 +2,9 @@

buildscript {
ext {
buildToolsVersion = "27.0.3"
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 27
compileSdkVersion = 28
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
Expand Down Expand Up @@ -32,6 +32,17 @@ allprojects {
}
}

// Set android-tools as maeven url for each broken packages
subprojects {project ->
if (project.name.contains('react-native-')) {
buildscript {
repositories {
maven { url "https://dl.bintray.com/android/android-tools/" }
}
}
}
}


task wrapper(type: Wrapper) {
gradleVersion = '4.4'
Expand Down

0 comments on commit eea3c58

Please sign in to comment.