How do I get Android Studio to include resources in a .jar file? - jar

I'm using Unity 5. It still expects java plugins to be a .jar file built with JDK 1.6.
I had this working under Unity 4, but they changed something. Now I get this error while building the apk from Unity:
OBSOLETE - Providing Android resources in Assets/Plugins/Android/res
is deprecated, please move your resources to an Android Library. See
"Building Plugins for Android" section of the Manual.
How do I get AS to put the resources into classes.jar? The "Building Plugins for Android" doesn't mention resources.
Additional information about my project:
The project references Google Play Services, so I need version.xml in there
<integer name="google_play_services_version">6587000</integer>
Which contains the version number for the reference in the Manifest.
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
But if I include this file in res/values in my AS library project, it's still output as an xml file in res/values next to the classes.jar.
Incidentally, I'm digging the .jar file out of
/ApplicationName/build/intermediates/exploded-aar/ProjectName/LibararyName/unspecified/classes.jar
after building the project.

First of all, this is a warning and not an error.
Providing resources in Unity in Assets/Plugins/Android/res/ folder is not recommended, because it can cause resource conflicts.
When you provide resources in an Android library, they are correctly merged during build process.
Basically, you have three options:
convert your plugin into an Android library. Or you can init an empty library, add your .jar file to bin/, your resources to res/ (there should be a manifest and android.library=true in project.properties). You can do this by calling android create lib-project (more details)
if you compile your plugin directly using gradle or in Android Studio, you can use .aar file produced, given that you have set your project up as a library (apply plugin: 'com.android.library' in your build.gradle file). Just put it in any folder of your project, it should automatically be detected as Android-only plugin.
continue providing resources in res/ and wait for it to be completely unsupported by Unity.
Hope this helps.

Related

Firebase Crashlytics NDK unstripped files

I have an SDK that uses C++ code. The SDK exports 4 different modules in a maven repo that I publish on either a local maven repo or on GitHub packages.
The apps that consume the SDK should be able to use Firebase Crashlytics and get reports of crashes in the native code as well.
The first problem I have is that I need to provide to the Firebase plugin the folders unstrippedNativeLibsDir and strippedNativeLibsDir:
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir "???"
strippedNativeLibsDir "???"
}
If I go to the project where I build the SDK I can see: build/intermediates/merged_native_libs/release and build/intermediates/stripped_native_libs.
Are these the unstripped and stripped folder respectively?
Is there any documentation about what exactly those folders are supposed to contain?
Anyway if I configure the app firebaseCrashlytics to point to these folders I still need to fix another issue.
I get:
Crashlytics could not find NDK build tasks on which to depend. You many need to manually enforce task dependencies
It looks like since I'm building the libs that use the NDK in another project, then the Firebase plugin does not work.
What am I supposed to do?
Is it possible to get the Crashlytics NDK working even if I build the libraries independently with a separate project?
The only way I made it work was to build the libraries along with the app. The libraries were in separate repos anyway but I included them as sub-repositories in the app.
In this way, you solve the issue of not finding NDK build tasks on which to depend.
I know this is not the answer though

Google Play ask for deobfuscation txt file, Xamarin Forms

When I previously released my application it went well, but now I try to upload a new version of my application and Google Play says that it has some java/kotlin code in it and asks for me to upload an deobfuscation txt file. I have been looking for answers and the people mention a "mapping.txt" file which android studio creates when you are using proguard or R8 code shrinkers.
Does anyone know where I can generate such file or where it may be?
Note: I haven't added or upgraded any nuget packages since the last time I updated the application and I already looked in the bin/obj folders with no luck. Also I checked the archive folder that creates when I bundle the application.
The obfuscation step of ProGuard is disabled when building a Xamarin Android application. Therefore, there's no deobfuscation file generated and no need to upload one. You can ignore the warning.
From the Xamarin.Android documentation:
The Xamarin.Android ProGuard configuration does not obfuscate the APK. In fact, it is not possible to enable obfuscation through ProGuard (even through the use of custom configuration files).
Edit: There is currently an open PR in Xamarin.Android to have ProGuard generate the mapping.txt file. Note that this is only to silence the warning, though. In theory, it's not needed.

How to integrate firebase in an Ionic project (android/iOS)?

I am reading articles and testing ways to implement analytics and push notifications in my Ionic app using firebase.
My ionic app targets both android and ios platforms, so where do I place the google-services.json firebase file? Do I have to create an 2 apps within firebase if I need to use firebase for android and iOS?
I am reading many articles some of which say root folder, whereas some mention to put it in the apps folder. Some say we have to then update the config.xml to include the foll:
<resource-file src="google-services.json" target="app\google-services.json" />
I have also read that we need to update the gradle file with application and project level dependencies.
I have put the file in platform/android/app folder and things are working correctly now.
I just want to know what is the best practice when using Ionic and Firebase, where do I place the file and what config changes do I have to make?:
For an Ionic android app
For Ionic iOS app
For Ionic app for both android and iOS platforms
Have a look at the documentation of the firebase plugin :
https://github.com/arnesson/cordova-plugin-firebase
For Android, you have the google-services.json file, and for iOS you have the GoogleService-Info.plist file. These files are required by firebase to work on both iOS and Android. You have to place theses files at the same level as config.xml.
This plugin uses a hook (after prepare) that copies the configuration
files to the right place, namely platforms/ios/\/Resources for ios and platforms/android for android.
So you don't need the resource-file directive in your config.xml, since it is copied automatically.
You don't need to edit the build.gradle file, but If you have other google play plugins installed (like maps or admob), the compilation may not work.
Your build may fail if you are installing multiple plugins that use
Google Play Services. This is caused by the plugins installing
different versions of the Google Play Services library. This can be
resolved by installing cordova-android-play-services-gradle-release.
If your build is still failing, you can try installing
cordova-android-firebase-gradle-release. For more info, read the
following comment about locking down the specific versions for play
services and firebase. It is suggested to use + instead of 15.+ to
ensure the correct versions are used.
EDIT : Since you're using cordova-plugin-firebase-analytics and not cordova-plugin-firebase, it seems that they didn't implement any hook to copy the files. You'll have to place these directives in your config.xml :
<platform name="android">
<resource-file src="google-services.json" target="app\google-services.json" />
...
<platform name="ios">
<resource-file src="GoogleService-Info.plist" />
...
Be sure to install cordova-support-google-services

Firebase Push notifications with PhoneGap Build using cordova-plugin-fcm

I need to implement push notifications in a PhoneGap Build app that I'm developing.
I didn't find much documentation on using the new Google service, Firebase Cloud Messaging (FCM), but since it is supposed to be what we have to use now I searched for an API that could make my life easier.
I found: https://www.npmjs.com/package/cordova-plugin-firebase
So I added to my config.xml:
<plugin name="cordova-plugin-fcm" source="npm" />
And put the google-services.json I've created from https://console.firebase.google.com/ in the root of the folder I zip to upload to the Phonegap Build.
But I get the following error:
Execution failed for task ':processReleaseGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
/project/src/release/google-services.json
/project/google-services.json
I created the "project" folder in the root and put the file there but that doesn't work neither.
Currently my app folder looks like:
\css
\img
\js
\res (icons and splashscreens)
index.html
config.xml
google-services.json
If anyone knows where I've to put that file or have any other way to implement this even using other API, I would really appreciate it.
I've never used Phonegap CLI, I've always been using Phonegap Build.
Cordova introduced the resource-file tag some time ago and it also works in Phonegap Build.
You can use that instead of a forked plugin to copy the google-services.json and GoogleService-Info.plist files
Put the in the root of your project and the use the resource-file tag in the config.xml like this:
If using cordova-android 7 or newer:
<platform name="android">
<resource-file src="google-services.json" target="app/google-services.json" />
</platform>
older versions
<platform name="android">
<resource-file src="google-services.json" target="google-services.json" />
</platform>
iOS
<platform name="ios">
<resource-file src="GoogleService-Info.plist" />
</platform>
You can also put it inside www folder, in that case in my examples add www/ before the file name in the src field.
https://cordova.apache.org/docs/en/7.x/config_ref/index.html#resource-file
The files need to be alongside the www folder, problem is that Phonegap Build only lets you upload the contents of said folder, so you can't upload the files.
Fortunately there's something you can do; Build installs the plugins directly from npm, and plugins can work thought the whole project, so what you need is a plugin that copies the files [google-services.json, GoogleService-Info.plist] for you.
Most of the work has already been done: cordova-plugin-fcm-config.
This plugin copies the required FCM configurations in the project root folders and Xcode project. It is used in combination with the great cordova-plugin-fcm plugin.
It wasn't built for this purpose but works wonderfully.
There's an added complexity though; since you can't upload plugins (you can only add a reference to it in your config.xml), and this plugin needs your own app configuration files, you'll have to:
Clone/Fork the plugin into your own repository.
Replace the configuration files.
Upload it somewhere Build can find.
Where do you upload it? That might be tricky. The infrastructure is built around the idea that plugins are for general purposes and can be configured in each project xml, so npm makes sense. But in this case your plugin will contain very specific data to your project, so uploading to npm would pollute the namespace in my opinion.
I don't know about you, but I have a paid account, so I publish the plugin in my own repository and submit as a private plugin. This is what I recommend.
For me I had to go into the .xcodeproj file and change Main Interface from MainViewController.xib to CDVLaunchScreen.storyboard
Rebuild and it worked. My app was built with Ionic and I started it in Ionic Creator.

Plugin is not recognized in QML Desktop Appication Deployment

I have wrote a Qt Quick Desktop application in c++ qnd Qt Creator(QML) on Windows7. Now I have to deploy it.
I'm using Qt Quick Desktop Components plugin in my application, I've installed it according to these instructions, and I'm using it with:"import Qt.labs.components", as written there.
I tried adding to the .pro file:
QML_IMPORT_PATH = C:\QtSDK\Desktop\Qt\4.7.4\mingw\imports\Qt\labs\components
but I saw it's working well without it, and I removed it.
I've read a guide how to deploy such an application here, and followed it; I have now a deployment folder, with: the .exe file, the needed dll's, and a folder hierarchy like:Qt/labs/components.
in components I put the styleplugin.dll(for desktop components), and a qmldir file, with the content: plugin styleplugin, excactly like in the doc.
but when I'm runnig my application.exe from the deployment folder in another computer, I'm getting a white, empty window, means: It didn't find the .dll file.
Should you explain me please what's wrong?
I know two reasons, when app can not load plugin dll:
Some of dependecies of the plugin dll are missing or can not be found and that is why it can not be loaded. Qt Creator or Visual Studio environment can be different than the system one. For example, your IDE can modify PATH environment variable. Check plugin's dependencies availability with Microsoft Dependency Walker tool in the same environment where you launch your app.
App can not find plugin in standard directories. To check this you should specify plugin import directory explicitly:
QDeclarativeView *rootView = new QDeclarativeView()
rootView->engine()->addImportPath(QLatin1String("path/to/your/imports"));

Resources