Start a new topic

Flutter SDK fluttersamples - change application ID

We are currently experimenting with applying our own application ID in the Wikitude Flutter SDK fluttersamples from GIT. The application ID is: com.wikitude.fluttersamples but when we change it, we have trouble compiling the project or we get a id mismatch when using the Custom URL functionality. I think the main problem is the "android/app/src/main/java/com/wikitude/fluttersamples/

MainActivity.java" where the id is specified and also the id is specified in some of the compiled binary files?


Binary files example from Wikitude GIT:
grep: ./android/.gradle/5.6.4/javaCompile/jarAnalysis.bin: binary file matches
grep: ./android/.gradle/5.6.4/javaCompile/classAnalysis.bin: binary file matches
grep: ./android/.gradle/5.6.4/executionHistory/executionHistory.bin: binary file matches


We are currently unable to publish an app in any app store.


Hi,


To get a better understanding, what are you trying to achieve by replacing ID's in our sample app? And where are you changing the ID's?


Here is a link to the Android official documentation talking about the ID's: https://developer.android.com/studio/build/application-id. What I would guess about the error you are mentioning is that you didn't change the com.wikitude.fluttersamples id everywhere, just in some places. This can't be done as the project is set to work under an specific package name.


To avoid this I would suggest to look for all the com.wikitude.fluttersamples appearances and modify them (this includes gradle files, androidmanifest.xml file and all java classes in the project). Nevertheless, our license key required to make the sample to work is set to an specific ID -> in this case com.wikitude.fluttersamples. Even if you manage to compile the project itself, you will also need to replace the license key with you own one.


Regards,


Aitor.

Hi.

Replacing ID's in your sample app is to to build an app as quickly as possible to replace the soon to be discontinued Wikitude App.


We are changing the IDs everywhere with this command in Ubuntu: find . -type f -exec sed -i 's/com.wikitude.fluttersamples/com.example.exampleappname/g' {} +
This results in a non runnable Flutterapp. I think it is possible to replicate a clean clone of the current git repository: https://github.com/Wikitude/wikitude-flutter-plugin-examples


Here is output from the grep command on a fresh clone from git:

grep -rn . -e "com.wikitude.fluttersamples"
./wikitude-flutter-plugin-examples/ios/Runner.xcodeproj/project.pbxproj:409:                            PRODUCT_BUNDLE_IDENTIFIER = com
.wikitude.fluttersamples;
./wikitude-flutter-plugin-examples/ios/Runner.xcodeproj/project.pbxproj:541:                            PRODUCT_BUNDLE_IDENTIFIER = com
.wikitude.fluttersamples;
./wikitude-flutter-plugin-examples/ios/Runner.xcodeproj/project.pbxproj:573:                            PRODUCT_BUNDLE_IDENTIFIER = com
.wikitude.fluttersamples;
./wikitude-flutter-plugin-examples/README.md:34:    AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPa
thList[[zip file "/data/app/com.wikitude.fluttersamples/base.apk"],nativeLibraryDirectories=[/data/app/com.wikitude.fluttersamples/lib/
arm, /data/app/com.wikitude.fluttersamples/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libflutter.so"
grep: ./wikitude-flutter-plugin-examples/.git/index: binary file matches
grep: ./wikitude-flutter-plugin-examples/android/.gradle/5.6.4/javaCompile/jarAnalysis.bin: binary file matches
grep: ./wikitude-flutter-plugin-examples/android/.gradle/5.6.4/javaCompile/classAnalysis.bin: binary file matches
grep: ./wikitude-flutter-plugin-examples/android/.gradle/5.6.4/executionHistory/executionHistory.bin: binary file matches
./wikitude-flutter-plugin-examples/android/app/src/debug/AndroidManifest.xml:2:    package="com.wikitude.fluttersamples">
./wikitude-flutter-plugin-examples/android/app/src/profile/AndroidManifest.xml:2:    package="com.wikitude.fluttersamples">
./wikitude-flutter-plugin-examples/android/app/src/main/AndroidManifest.xml:2:    package="com.wikitude.fluttersamples">
./wikitude-flutter-plugin-examples/android/app/src/main/AndroidManifest.xml:37:            android:name="com.wikitude.fluttersamples.Ma
inActivity"
./wikitude-flutter-plugin-examples/android/app/src/main/java/com/wikitude/fluttersamples/MainActivity.java:1:package com.wikitude.flutt
ersamples;
./wikitude-flutter-plugin-examples/android/app/build.gradle:37:        applicationId "com.wikitude.fluttersamples"

We will be using the Wikitude Studio Hosting feature to publish 18 different Wikitude Studio projects in an IOS and Android app. Projects should be listed like the current "Samples" in the app (samples.json).


Thank you!

Ooh, I forgot to add. So the app is not able to compile/run/build at all if we don't provide our own license key?


Thank you.

Hi,


I could make the project work by downloading it by scratch, calling flutter pub get and install the apk in a device. Nevertheless, after changing the IDs as you did, I'm also having a lot of issues to make it work, but that is expected as not only the files IDs should be change, but also some of the folder structure -> android/app/src/main/java/com/wikitude/fluttersamples/MainActivity.java.


After applying some manual changes, I still couldn't make it work, so what I would suggest is to create a project from scratch and import the plugin into that project.


The license key is checked at runtime, when a sample is opened. Even if you are not providing a license key, the project itself should be able to compile and the application should be able to install in a device.


Regards,


Aitor.

Hi Aitor.


Thank you for the feedback!


Yes, this is our experience too. We really need the ability to change the APP ID, so we can publish our own app based on the Flutter SDK sample. The reason is that there are many dependencies that are not satisfied in a vanilla flutter project, and I guess it will be easier to change the APP ID than building this from scratch. We already have our initial app ready based on the Flutter SDK sample, the only thing we need is to change the APP ID.


OK, thank you for the info regarding the license key.


Thank you!

Hi,


After a lot of investigation I can confirm that changing the APP ID is corrupting some gradle files which I couldn't properly fix. Nevertheless I could create a project from scratch and copy most of the code from our sample app.


The steps are the following:

  1. Create a new project with Flutter 2.2.0.
  2. Change the gradle version inside the android folder as follows:
    1. android/build.gradle -> com.android.tools.build:gradle should point to 3.6.0.
    2. android/gradle/wrapper/gradle-wrapper.properties -> distributionUrl should point to https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
    3. android/app/build.gradle -> minSdkVersion must be 23.
  3. Download the plugin from https://www.wikitude.com/download-wikitude-sdk-for-flutter/ and add it to your project with the same structure as the other project.
  4. Make sure to copy the permissions and the arcore metadata from the AndroidManifest.xml file.
  5. From now on you will be able to copy all dart files inside the lib folder and all dependencies included in the yaml file.


If you find out a way to fix the gradle corrupted files, please let us know. Hopefully with our next release all gradle issues will be gone for new vanilla flutter projects.


Regards,


Aitor.

Hi Aitor.


Thank you for the information.


Yes, we managed to fix original project and we are up and running with the ios and android apps with the trial license. We need to do the rest tinkering with having both license keys in the same code-base. I don't think there is any mention of that in the documentation?

You should remove the android/.gradle folder from your git and then do the adjustments also adjust the folder structure as you suggested earlier.


Thank you!

Hi,


In https://www.wikitude.com/external/doc/documentation/latest/flutter/triallicense.html#license-key it mentions where to put it. The file you are looking for it the arview.dart where there is a variable called licenseKey which should be changed. The same license key should work for Android and iOS.


Regards,


Aitor.

Login or Signup to post a comment