Build version 4.0.9 of OsmAnd with improved build script

The 4.0.7 version allows purchases to be accessed via the downloads
menu, causing a crash. Similarly a null pointer during a start up
attempt to access subscriptions was reported. Simple adjustments have
been made to avoid the null pointer. I have not been able to reproduce
the start up call to the subscriptions, so do not know the consequences
of the null pointer fix.
This commit is contained in:
Matthew Hague 2021-09-23 09:41:45 +01:00 committed by Marcus
parent a8d725a9fc
commit 8921cedeb2

View file

@ -4226,6 +4226,126 @@ Builds:
- cp $$icu50-2-1-patched$$/icu4j/icu4j.jar ../OsmAnd-java/libs/
ndk: r17c
- versionName: 4.0.9
versionCode: 409
commit: v4.0.9
subdir: android/OsmAnd
submodules: true
sudo:
- apt-get update || apt-get update
- apt-get install --yes swig
gradle:
- android
- full
- legacy
- fat
srclibs:
- icu50-2-1-patched@0d825a9779eeb8ee35977ddf8bb4bea4119bf638
- osmand-external-skia@android/oreo
rm:
- android/OsmAnd-java/libs/*.jar
- android/OsmAnd/libs/*.jar
- android/OsmAnd-telegram/
- help/website/images/features.zip
- resources/icons/tools/SVGtoXML/vd-tool
prebuild:
- sed -i -e "/.*OsmAndCore.*SNAPSHOT.*/d" build-common.gradle
- sed -i -e "/.*OsmAndCore.*SNAPSHOT.*/d" build.gradle
- sed -i -e "/ivy {/,+6d" ../build.gradle
- rm build-library.gradle
- perl -i -0 -p -e "s|maven {\n\s*url 'https://developer.huawei.com/repo/'\n\s*}||g"
../build.gradle
- sed -i -e "/huaweiImplementation/d" build.gradle
- sed -i -e "s/System.getenv(\"APK_VERSION\")/\"$$VERSION$$\"/g" build.gradle
- sed -i -e "s/System.getenv(\"APK_NUMBER_VERSION\")/\"$$VERCODE$$\"/g" build.gradle
- sed -i -e "s/System.getenv(\"TARGET_APP_NAME\")/\"OsmAnd~\"/g" build.gradle
- "sed -i -e \"s/implementation fileTree.*/implementation fileTree(include:\
\ ['icu4j.jar'], dir: 'libs')\\n implementation group: 'net.sf.trove4j', name:\
\ 'trove4j', version: '3.0.3'\\n/\" ../OsmAnd-java/build.gradle"
- "sed -i -e \"s/implementation fileTree.*/implementation fileTree(include:\
\ ['classes.jar','icu4j.jar'], dir: 'libs')\\n implementation group: 'net.sf.trove4j',\
\ name: 'trove4j', version: '3.0.3'\\n/\" build-common.gradle"
- sed -i -e "s/, ':OsmAnd-telegram'//" ../settings.gradle
- pushd ../../core-legacy/externals
- sed -i "s/# Extract/sha256sum \$SRCLOC\/upstream.tar.bz2 | grep 13bfc5ae543cf3aa180ac2485c0bc89495e3ae711fc6fab4f8ffe90dfb4bb677
|| { echo 'Failed checksum' 1>\&2; exit; }/" protobuf/configure.sh
- sed -i "/# Download/,+8d" skia/configure.sh
- sed -i "s/# Patch/cp -r $(echo $$osmand-external-skia$$ | sed 's/\//\\\//g')
\$SRCLOC\/upstream.original/" skia/configure.sh
- popd
- echo -e "\norg.gradle.jvmargs=-XX:MaxHeapSize=2048m" >> ../gradle.properties
- sed -i -e "/.*com.google.android.play.*/d" build-common.gradle
- "echo \" package net.osmand.plus.helpers; import net.osmand.plus.OsmandApplication;\
\ import net.osmand.plus.activities.MapActivity; import androidx.annotation.Nullable;\
\ import androidx.fragment.app.FragmentActivity;\npublic class RateUsHelper\
\ { public RateUsHelper() { } public void storeRateResult(FragmentActivity\
\ activity) { } public void updateState(@Nullable RateUsState state) { } public\
\ static boolean shouldShowRateDialog(OsmandApplication app) { return false;\
\ } public static void showRateDialog(MapActivity mapActivity) { } public\
\ enum RateUsState { INITIAL_STATE, IGNORED, LIKED, DISLIKED_WITH_MESSAGE,\
\ DISLIKED_WITHOUT_MESSAGE, DISLIKED_OR_IGNORED_AGAIN; } }\" > src/net/osmand/plus/helpers/RateUsHelper.java"
- sed -i -e "/.*com.amazon.in-app-purchasing.*/d" build.gradle
- sed -i -e "/.*com.android.billingclient.*/d" build-common.gradle
- echo " package net.osmand.plus.inapp; import android.app.Activity; import
android.content.Context; import androidx.annotation.NonNull; import androidx.annotation.Nullable;
import net.osmand.plus.OsmandApplication; import java.lang.ref.WeakReference;
public class InAppPurchaseHelperImpl extends InAppPurchaseHelper { public
InAppPurchaseHelperImpl(OsmandApplication ctx) { super(ctx); } public void
isInAppPurchaseSupported(@NonNull final Activity activity, @Nullable final
InAppPurchaseInitCallback callback) { } protected void execImpl(@NonNull final
InAppPurchaseTaskType taskType, @NonNull final InAppCommand runnable) { }
public void purchaseFullVersion(@NonNull final Activity activity) { } public
void purchaseDepthContours(@NonNull final Activity activity) { } public void
purchaseContourLines(@NonNull Activity activity) throws UnsupportedOperationException
{ } public void manageSubscription(@NonNull Context ctx, @Nullable String
sku) { } protected InAppCommand getPurchaseSubscriptionCommand(final WeakReference<Activity>
activity, final String sku, final String userInfo) { return null; } protected
InAppCommand getRequestInventoryCommand(boolean userRequested) { return null;
} protected boolean isBillingManagerExists() { return false; } protected void
destroyBillingManager() { } } " > src-google/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java
- rm src-google/net/osmand/plus/inapp/util/BillingManager.java
- rm src-google/net/osmand/plus/inapp/InAppPurchasesImpl.java
- perl -i -0 -p -e 's|<Preference\n.*android:key="purchases_settings"(.*\n){9}||g'
res/xml/settings_main_screen.xml
- sed -i -e "/.*Preference purchasesSettings.*/,+1d" src/net/osmand/plus/settings/fragments/MainSettingsFragment.java
- sed -i -e "/addRestorePurchasesRow();/d" src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java
- sed -i -e "s/return purchases.getSubscriptions();/return new InAppSubscriptionList(new
InAppSubscription[] { }) { };/" src/net/osmand/plus/inapp/InAppPurchaseHelper.java
- sed -i -e "s/return purchases\..*;/return null;/" src/net/osmand/plus/inapp/InAppPurchaseHelper.java
scanignore:
- help/website/fonts/*.woff
- help/website/fonts/*.eot
- help/website/fonts/*.ttf
- resources/voice/tr/voice/*.ogg
scandelete:
- resources/test-resources
build:
- pushd ../../OsmAnd-core/wrappers/android/
- sed -i -e "/Native/d" settings.gradle
- sed -i -e "/Native/d" build.gradle
- sed -i -e "/compileTask.*copyNdkSharedLibs/d" build.gradle
- sed -i -e "/compileTask.*copyQtSharedLibs/d" build.gradle
- sed -i -e "/compileTask.*copyQtJarLibs/d" build.gradle
- gradle assembleRelease
- cd build/outputs/aar
- unzip OsmAndCore_android-release.aar
- cp classes.jar ../../../../../../android/OsmAnd/libs/
- popd
- pushd $$icu50-2-1-patched$$/icu4j
- ant jar
- zip -d icu4j.jar "com/ibm/icu/impl/data/icudt50b/brkitr/*"
- zip -d icu4j.jar "com/ibm/icu/impl/data/icudt50b/coll/*"
- zip -d icu4j.jar "com/ibm/icu/impl/data/icudt50b/curr/*"
- zip -d icu4j.jar "com/ibm/icu/impl/data/icudt50b/lang/*"
- zip -d icu4j.jar "com/ibm/icu/impl/data/icudt50b/rbnf/*"
- zip -d icu4j.jar "com/ibm/icu/impl/data/icudt50b/region/*"
- zip -d icu4j.jar "com/ibm/icu/impl/data/icudt50b/translit/*"
- zip -d icu4j.jar "com/ibm/icu/impl/data/icudt50b/zone/*"
- popd
- cp $$icu50-2-1-patched$$/icu4j/icu4j.jar libs/
- cp $$icu50-2-1-patched$$/icu4j/icu4j.jar ../OsmAnd-java/libs/
ndk: r19c
MaintainerNotes: |-
Update CV only after sucessfully built and tested.
@ -4286,7 +4406,14 @@ MaintainerNotes: |-
The next perl command removes to purchases_settings from the
settings screen as the stubs will crash if OsmAnd actually tries to
use them. The MainSettingFragment is also updated to avoid trying to
manipulate the removed setting.
manipulate the removed setting. Similarly, the removal of
addRestorePurchasesRow prevents the restore purchases option on the
downloads page.
Then, since a start up attempt to get subscriptions was reported,
various lines in InAppPurchaseHelper.java are adjusted to avoid
attempting to access a null purchases variable. This has not be
tested to ensure there are not consequences down the line.
AutoUpdateMode: None
UpdateCheckMode: None