I am having a publishing a release build of my xamarin android app. I recently implemented firebase messenging along with the associated google play services and have all the latest nuget packages installed. However, I still have this showing in my visual studio references -
I was dealing with the proguard issue, java.exe exited with error code 1 and added a proguard file with the following lines -
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep class com.google.firebase.** { *; }
-dontwarn com.google.firebase.**
This allowed the app to build but not it just hangs on the splash screen and doesn't goes dark.
Before I got this far I posted here while I was looking for ways to fix my proguard issue. Everything is peachy in a debug release mode but this release build is leaving me without many clues.
Related
Severity Code Description Project File Line Suppression State
Error The "Xamarin.Android.Tasks.GetApiLevelFromFramework" task could not be loaded from the assembly C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Build.Tasks.dll. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. xamarin_installed_trial
I get this error when I want to run an android program using xamarin.
Android sdk is properly installedhere is the error
Can you check the target platforms are installed correctly. In Visual Studio ->Android SDK MANAGER -> Platforms
You can check
here
I try to resolve this issue last few days, still without success.
If I build release version without proguard then everything is OK.
I read many topics about possible problems but nothing help in my case.
So far I did as follow:
Java max heap size - 1G
Use "mklink" - mklink /j C:\android-sdk “C:\Program Files (x86)\Android\android-sdk”
Created own proguard.cfg with content:
General Android
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
Android Support Library
-keep class android.support.multidex.MultiDexApplication
-keep class android.support.v4.**
-keep class android.support.v7.** {
public *; }
Google Play Billing
-keep class com.android.vending.billing.**
Google Play Services
-dontwarn com.google.android.gms.internal.*
-keep class * extends java.util.ListResourceBundle {
protected java.lang.Object[][] getContents(); }
Manually update ProGuard to latest version.
And the result is 0 warnings and 1 error.
ERROR:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1929,3):
error MSB6006: "java.exe" exited with code 1.
What else can I do?
Please help.
Update.
I created brand new app "Xamarin Hello World" and there "ProGuard" works. So it must be something wrong with my app not a system.
But visual studio doesn't show me any other error apart that Java code 1. So how to track where is a problem?
UPDATE
The problem was in my "proguard.cfg" file. I copy content from other source and one line there should be comment but it wasn't. So this problem gone. But now some warnings come out:
2>PROGUARD : warning : can't write resource [META-INF/MANIFEST.MF](Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])
2>Copying resources from program jar [G:\ApkiC-Sharp\GNote\GNote\GNote.Android\obj\Release\__library_projects__\Xamarin.GooglePlayServices.Basement\library_project_imports\classes.jar](TaskId:345)
2>PROGUARD : warning : can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])
2>Copying resources from program jar [G:\ApkiC-Sharp\GNote\GNote\GNote.Android\obj\Release\__library_projects__\Xamarin.GooglePlayServices.Maps\library_project_imports\classes.jar] (TaskId:345)
2>PROGUARD : warning : can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])
2>Copying resources from program jar [G:\ApkiC-Sharp\GNote\GNote\GNote.Android\obj\Release\__library_projects__\Xamarin.GooglePlayServices.Tasks\library_project_imports\classes.jar] (TaskId:345)
2>PROGUARD : warning : can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])
What dose it mean? Is it something to worried about?
How to check if "ProGuard" works fine?
I was also facing the same issue on my Windows 10 x64 and visual studio 2015. I have set the JDK path to JDK 1.8 under android settings in Visual studio tools ->options ->xamarin ->java development kit location. it was pointing to "C:\Program Files (x86)\Java\jdk1.7.0_55" and I made it to "C:\Program Files\Java\jdk1.8.0_31", and issue has been fixed.
Try enabling the Multi-Dex compilation option.
I want to be able to run Xamarin.Forms from source so I can set breakpoints etc in it. I want to do this primarily so I can see how things get called so I can better understand how it works in response to my use of it in my app. I don't want to do it in the final app, I'd just like to swap out the source version for the nuget package in the end. During development though I would like to see how it runs things to better understand how I can manipulate/override/implement different details.
So far I am close to getting it to compile with my project, but I get 2 build issues realated to Xamarin.Forms.Conrols.Issues I think they are just unit tests, but it stops the build.
/Users/username/github/Xamarin/Xamarin.Forms/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39636.xaml: Error: Object reference not set to an instance of an object (Xamarin.Forms.Controls)
And
/Users/username/github/Xamarin/Xamarin.Forms/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/PlatformSpecifics_iOSTranslucentNavBarX.xaml: Error: Object reference not set to an instance of an object (Xamarin.Forms.Controls)
Maybe there is a better way to run it from source and have it integrate with a project and I am just missing it?
These are the projects I have added to my project in a Solution Folder:
Maybe I am on the right path, maybe not. Currently I am only targeting iOS I have an Android project but I am not concerned with that at the moment, just trying to limit it to running on iOS. If that's an issue I can definitely change it. It shouldn't care about the Android parts if I am building for iOS only. Maybe it does?
... LATER ...
Ok tinkering some more I got it down to these packages:
When I right click on the solution folder and select: "Build Xamarin.Forms" the build succeeds. It only fails now with the following error when I try to build my app's Form's project:
/Users/username/github/Xamarin/MyProject/App.xaml.cs(13,13): Error CS0103: The name 'InitializeComponent' does not exist in the current context (CS0103) (MyProject)
I get 51 errors whenever it references anything inside Xamarin.Forms or when it's trying to access a x:Name in some XAML from the code behind.
Intellisense sees the method as well, in this case InitializeComponent so at least that seems to know about it.
Ok, I got it. Here's how I did it:
Clone the Xamarin.Formsrepo from github:
https://github.com/xamarin/Xamarin.Forms
The following applies to Xamarin.Forms 2.3.4.247
cd into the newly cloned repo and checkout that tag corresponding to Xamarin Forms v2.3.4.247:
$ git clone git#github.com:xamarin/Xamarin.Forms.git
$ cd Xamarin.Forms
$ git checkout 2.3.4-2
Add these projects into your project. I placed them in a new solution folder within the project in Visual Studio Mac. I was only concerned with iOS. It would be similar for Android, just adding those specific libs. To figure how the dependencies I just opened the Xamarin.Forms.sln file and check each project's references.
Xamarin.Forms.Platform
Xamarin.Forms.Core
Xamarin.Forms.Platform.iOS
Xamarin.Forms.Xaml
Xamarin.Forms.Build.Tasks
Xamarin.Forms.Xaml.Xamlc
Xamarin.Forms.Xaml.Xamlg
Next, update packages for Xamarin.Forms.Build.Tasks (Mono.Cecil is missing when you import this project. It has a little warning icon by it in the packages list UI)
Now cd to your project folder and copy the .nu* files from the Xamarin.Forms Repo:
$ ls -1
Xamarin.Forms
YourProject
$ cd YourProject
$ cp -r ../Xamarin.Forms/.nu* ./
Afterwards, in the following to csprojfiles (The forms project and the platform project):
YourProject/YourProject/YourProject.csproj
YourProject/iOS/SourceTest.iOS.csproj
file add the following <Import> at the bottom before </Project>:
<Import Project="..\.nuspec\Xamarin.Forms.targets" Condition="Exists('..\.nuspec\Xamarin.Forms.targets')" />
Note this is referencing the files we copied above.
Finally it's time to add the references in Visual Studio to both projects.
Forms Project
Platform Project
That's it. It should compile now and you can add breakpoints into Xamarin.Forms and see how things run. Be sure you added that <Import> node above to ALL csproj files using Xamarin.Forms. From the looks of it, It's responsible for triggering XamlC to process the XAML. When you install Xamarin.Forms from Nuget, it adds this for you. Also be sure you have copied the *.nu files mentioned above to the root of your solution directory.
Remember, once you are done tinkering and you decide to install the Nuget Xamarin.Forms package, you may need to undo some of the changes you made above. For example, check the csproj files to be sure the <Import> is only from the package install.
In case you get compiler errors, check the Xamarin project references. Here are the individual Xamarin related inter-project dependencies that I used to generate the project reference list above.
Xamarin.Forms.Core
References
Xamarin.Forms.Platform
Xamarin.Forms.Platform
References
None
Xamarin.Forms.Platform.iOS
References
Xamarin.Forms.Core
Xamarin.Forms.Xaml
References
Xamarin.Forms.Core
Xamarin.Forms.Xaml.Xamlc
References
Xamarin.Forms.Build.Tasks
Xamarin.Forms.Xaml.Xamlg
References
Xamarin.Forms.Build.Tasks
Xamarin.Forms.Build.Tasks
References
Xamarin.Forms.Core
Xamarin.Forms.Xaml
In addition to AJ Venturella's answer, you also need in 2022:
...
<Import Project="..\..\.nuspec\Xamarin.Forms.targets" />
<Import Project="..\..\.nuspec\Xamarin.Forms.props" />
<Import Project="..\..\.nuspec\Xamarin.Forms.DefaultItems.targets" />
<Import Project="..\..\.nuspec\Xamarin.Forms.DefaultItems.props" />
</Project>
Open .nuspec\Xamarin.Forms.nuspec and check the content that targets "build". It's what's above.
When I try to build the application I get an exception the following exception :
C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(681,3): error : Failed to resolve assembly: 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
I tried cleaning the project and building it again, also updated the Xamarin.Forms packages but still with no luck.
A little overview on the stack trace :
2>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(681,3): error : Failed to resolve assembly: 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
2> Tool /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch execution finished. (TaskId:153)
2> MTouch: 2016-07-05T14:27:15.8191415+05:30 - Finished (TaskId:153)
2> Output Item(s): _NativeLibrary= (TaskId:153)
2>Done executing task "MTouch" -- FAILED. (TaskId:153)
Has anyone received this error? I am running the latest Xamarin for Visual Studio.
As mentioned in the comments above by #SushiHangover Java.Interop.dll is from Xamarin.Android and I was getting an error in Xamarin.IOS.
I had a reference of Mono.Android in PCL which is always referenced in Xamarin.IOS so indirectly I was referencing dll of Xamarin.Android to Xamarin.IOS. Removing the reference from PCL solved my problem.
Step-by-step instructions on how to fish this one out, as it took me some time to find where the 'Android polluted' peace of code was.
Unload your Common code project
Open .csproj look for something like this
<ItemGroup>
<Reference Include="Mono.Android">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v11.0\Mono.Android.dll</HintPath>
</Reference>
Delete this segment from csproj.
Load the project
Clean and rebuild the solution having iOS as startup Project, at this point, you will get a build error that will show which .cs file fails to build due to missing reference.
Go there and move the mechanism to an Android specific project.
As mentioned by #AkashAmin 'Mono.Android' referenced should not be there in PCL project.
But with this, also make sure that you have not added any 'Android' specific code in PCL project by adding 'using Android', if this was done then you need to remove this code by using 'Dependency Services', Click here
I had the same problem and when I removed the android.mono reference from pcl project it worked fine.
I think it happens because we are building project in ios and it doesn't have any android libraries
Platform specific code within the Shared Project will cause iOS compiler to attempt to use the platform specific assemblies when compiling.
In my case, I had a reference within my Shared Project's code, within the "using" statements, which was causing iOS to attempt to link to Android specific assemblies.
Removing the code from the Shared Project allowed for successful compiling of the project.
Just in case, I got this error from working with ReSharper on VS2013 (https://bugzilla.xamarin.com/show_bug.cgi?id=41627).
What I did was use the Workaround to explicitly add java.interop.dll assembly to my project. This problem doesn't affect Build so you can deploy first and VS will download java.interop to your app's obj\Debug\linksrc folder, which you can reference...
You need to check your PLC project on Android link. In PLC project ctrl+f and lets go find "Android" and delete it.
First I cloned github repository on my local machine. Then open Existing Android Studio project and selected "example" folder from the repo on the local machine. Then I got:
There were two events log :
1. Unlinked Gradle project?
2. Android Framework detected
When I clicked on the link for linking to Gradle "Improt project from gradle" dialogue box opened and then I got "Resolve Error" dialogue box with error:
Could not download artifact 'gradle.jar (com.android.tools.build:gradle:0.14.4)': No cached version available for offline mode
My Android Studio version:
I have searched on the Google and stack Overflow, but can't find appropriate solution.
You can't import the Swipecards repo in Android Studio 1.0.1 using gradle.
This project is using this unsupported version of gradle-plugin.
classpath 'com.android.tools.build:gradle:0.14.4'
I suggest you cloning the repo locally changing these values: classpath 'com.android.tools.build:gradle:1.0.0' in build.gradle distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip in gradle/wrapper/gradle-wrapper.properties