Attribute "imageAspectRatioAdjust" already defined with incompatible format.(APT0000) - android

My game is able to build and run on debug mode so I was hoping it would be ready to be built in release mode but I'm currently stuck with this error in the title. Anyone knows the solution?
EDIT : I've tried commenting the imageAspectRatioAdjust in common_attrs.xml but it would cause alot more different errors.
EDIT : I've found out that there is two file that contains imageAspectRatioAdjust in the release folder of my game when I tried to build it, but there is only 1 file that contains imageAspectRationAdjust in debug. Even if I tried to delete one or the other, I have to clean and rebuild and it would reappear again in the same folders.

I've added Facebook Android SDK into a sub project which a main project is dependant on, which requires me to add Facebook Android SDK into the main project as well but I've accidentally updated some of the packages in the component on the main project and did not update the packages on the sub project, which seems to be the cause of this error.

Related

Visual Studio 2017 - Xamarin - The file "obj\Debug\android\bin\packaged_resources" does not exist

I'm fighting with that issue for 2 days already and can't find any solution.
I have an Xamarin Android app in Visual Studio 2017 consisting of three projects:
Xamarin.Android project (main one)
Android-specific unit tests run on the device - project of type NUnit 3 Test Project (Android) created using NUnit Templates for Visual Studio
Platform-independent unit tests project (project of type Unit Test Project (.NET Framework))
Everything worked just fine until now. When I selected my main project as the Startup one, my app was deployed to the device/emulator. When I selected my Android-specific unit tests project, the test project was deployed and unit tests executed by nUnit Xamarin Runners on the device/emulator.
However few days ago I updated my Visual Studio 2017 with the newest available update and now, when trying to build this android-specific unit tests project I get the following error:
The file "obj\Debug\android\bin\packaged_resources" does not exist.
I've searched everywhere, including this and this SO topics. I also totally reinstalled Visual Studio 2017 and Xamarin with Android SDK included. Nothing helped. From what I read I suspect there is something wrong with the versions of Android SDK Build-tools I have installed. Here's what I have currently installed in SDK Manager:
As the other SO threads suggested, I tried uninstalling the newest Android SDK Build-tools (25.0.2) and installed version 23.0.3 (all my projects target Android 6.0), but it also doesn't help, I still have the same error.
Maybe it's worth adding that this issue may have started to happen when I tried to implement RecyclerView in my app reading this tutorial, where they suggested to install Android 7.1.1 (API 25) in SDK Manager. However I undoed my all changes after that and even reintalled VS2017 + Xamarin.
Do you have any other idea why this can be ? I'd really appreciate any help. Thanks!
EDIT 2017-04-09:
Egh, I removed VS2017, installed VS2015 with brand new Android SDK and still the same issue :(
I've finally found what was the issue. It wasn't related to any component from SDK Manager or VS version.
Following localization tutorial from developer.xamarin.com, I played a bit with Strings.xml in my Android project. I wanted to have my Activities Label taken from resources as well, so in the ActivityAttribute I defined:
[Activity(Label = "#string/peopleListTitle")]
and added this value in Strings.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-------Other resources values ----->
<string name="peopleListTitle">People List</string>
</resources>
In that case my build is failing with above-mentioned error:
The file "obj\Debug\android\bin\packaged_resources" does not exist
When I change ActivityAttribute to use a string directly:
[Activity(Label = "People List")]
the build is passing without any issues.
I managed to find a solution, but actually I don't know why it's not building when I try to use Label text defined in Strings.xml.
BTW, I managed to find what's the problem by setting build output verbosity to Diagnostic in Tools -> Options -> Projects and Solutions -> Build and Run which gives a detailed info why the build failed in the Output window.
I had the same problem. After removing the dash "-" sign from the image file name, the problem is solved. Bad error message! It should not be:
The file "obj\Debug\android\bin\packaged_resources" does not exist.
Writing an error message like this causing the Developer to think about something else while the problem is the illegal file name.
I had the same issue when I added a new image as a resource.
There was a '-' in the file name (Invalid resource name character). I renamed & removed that character and all good.
Resource name can only consist of 0-9,a-z or A-Z or combination of any.
I had the same problem, and i removed all image file name have "-" character. My problem solved
Another reason for this error is that you may have a float number as your version number. In my case I changed it to a integer and everything worked fine. (I found the error by switching the build output to Detailed)
Simply it worked.
In one case I copied and pasted previous working "packaged_resources"
in the bin folder.[the problem was it did not reflect the UI changes]
Other I opened the visual studio as
administrator.
Next changed the "Minimum target to Android" to lower
apis in the project properties windows.
I suggest not touching the code behind of the design. If you get this error simply pull some button from the tool bar into the design and visual studio will come to its consciousness that there is change in UI. Next click on save all so that it make necessary change in the designer file.
Mine was a different solution (and only half a day lost): I was having trouble getting Hockey app to match crashes against the correct version of the app and realised it uses VersionCode not VersionName so I change my code to "0.0.34" the same as the name. For some still unknown reason the app built and deployed to devices for about 3 days before I started getting this error The file "obj\Debug\android\bin\packaged_resources" does not exist. Setting it back to a numeric value fixed the problem.
I found the problem by looking back through my GIT logs and rebuild each push until I found the one that caused the problem.
It just because the Version Code,I set Code by '1.0',The file "obj\Debug\android\bin\packaged_resources" does not exist.;And I set it by '1',everything is ok.
Had the same error, the way I got over it was crank up the Android SDK manager and install all updates and remove any obsolete packages. This happened to me because I was targeting something newer which was not installed.
Check to see if there are any unused entries in resources.designer.cs if there are any manually remove those entries.
This will fix the issue.
After following several online suggestions - updating SDK, updating Xamarin etc - none of which worked for me.
Finally found that I had an activity for a Android provider to Alarm clock in my AndroidManifest file as below
<activity
android:name="com.njcommuter.droid/android.provider.AlarmClock"
android:label="AlarmClock"
.....
/>
Removing this line - and rebuilding worked fine without any errors and was able to deploy solution successfully.
Note : testing this by putting the line back, and I get same error again on rebuilding.
It can be linked to using any android provider which creates the package for it, not necessarily AlarmClock only.
This error is, somewhat of, a wrapper for what can be multiple reasons that that the file was not created. The key is to look in the detailed output and look for the underlying error causing the file creation failure.
In my case, I had corrupted icon.png files (generated right from from the VS xamarin nunit template, no less!). Once I put in valid png files, everything was built fine.
Another reason for this error, if that the android NDK (not android SDK) isn't right, change de version can resolve the problem: go to Tools/Options/Xamarin/android Configurator and change de folder, in my case I've three, the last one can't compile, but the second folder with version xx.r11c do it.
For me it was Target Android Version.I had it set to
but changing it to Compiling version(for me it was the latest platform) resolved the issue.

android studio cannot resolve symbol R [duplicate]

This question already has answers here:
"cannot resolve symbol R" in Android Studio
(100 answers)
Closed 7 years ago.
I've been working on an app and all was going well, everything was working fine. Then I modified some code in my main activity, and when I tried to run the app, there was an apparent error in my code and the build failed.
After this, all the references to my layout files were no longer working (i.e., R.layout.) R was red and hover over says "Cannot resolve symbol R".
Searching you will find dozens of posts that propose many fixes, like: Clean Project; Rebuild Project; Sync Project with Gradle Files; Invalidate Cashes / Restart; Check xml for errors, restart Studio, etc... I've tried them all.
NONE OF WHICH WORK IN MY SITUATION.
My code is working and without errors because I can create a new Android Studio project, and add my classes and resources. The new Android Studio project will run the the SAME CODE under a different package name.
I encountered this same problem a while back and I vaguely remember deleting something from my project folder (might have been a folder or file). I don't remember what I deleted, but it did fix the problem.
Thanks for any advice.
I finally got Android Studio to build without errors, but honestly I don't know how this happened. It was very puzzling that I could have a project that worked and several copies that didn't (I must have re-created my project 10 times from scratch) each time I would copy the project to an archive directory and start over. One of my build requirements was I needed to compile on Jelly Bean, and I think Android Studio sets some sort of defaults when you open a new project with a Blank Activity. Anyway, each time the R. error occurred the build warning would display this:
<style name="Base.Widget.AppCompat.Spinner.Underlined" parent="android:Widget.Material.Spinner.Underlined
But my code does not contain a spinner, so I really can't figure out where this is coming from. In fact I've tried to replace files in one of my inoperable saved projects with the files from my working copy (manifests, code, gradle.build, etc.) yet once inoperable, it seems a Studio project will remain that way.
I wish I could reproduce the problem but I cannot.
WTF! After thinking I had resolved this the problem, it is back again. From my working project I did 2 things. Added a very simple activity, and added it's reference to the manifest. Tried to run the project and get the SAME error again, referencing the a spinner. The Gradle build message is:
C:\CargoBay\Android\LandApp\app\build\intermediates\res\merged\debug\values-ldltr-v21\values-ldltr-v21.xml
Error:(3) Error retrieving parent for item: No resource found that
matches the given name 'android:Widget.Material.Spinner.Underlined'.
I removed the new code from my project, and it still won't build.
I don't know what to think now.
In Android Studio select your project folder, go to VCS / Local History / Show History. Show History will list any files that were moved or deleted, and give you an option to restore the file.
If you select your main activity code, it shows the history of code changes, and you can restore to previous code that was working.

Adding google maps library to existing project creates confusing error

I am building an Android app that I want to open google maps with the click of a button. I want the app to find the current location of the user and give them directions to a predefined address. I started building the application before I realized there were special steps that you have to take to include this functionality. To add this feature to my project I followed the directions on these two sites:
https://developer.android.com/google/play-services/setup.html
https://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject
The problem is on the second site, when i added the library to my already existing project it caused all of my code that has findViewById(R.id.whatever) or setContentView(R.layout.whatever) to become errors. It is now telling me that i need to import the class R. If I do that it then gives me error messages on the names of all my xml files.
For example in my MainActivity it is telling me that i should change setContentView(R.layout.activity_main) to setContentView(R.layout.activity_list_item) and does this for all references to my xml files for the entire project.
I tried going back and removing the google play services library from the project and starting over but when I removed it the errors still persists. I also tried using the "fix project setup" option in Eclipse but it didn't fix the problem.
I'm wondering if anyone here has experienced this problem before? If so, how can I fix it? The application had no errors before I tried to include the google play services library. I am new to Android development so a lot of the information I have found has been either confusing to understand or doesn't seem to include enough details for me to figure it out. Thanks for your help!
Look at your imports, and check if you are importing the correct R.java from your application package, not from the android package.
Check also if your XMLs don't contain errors, otherwise R.java won't be generated.
In my case android-maps-library had to errors in two files (I have forgotten their names), I edited the two files removing errors my self. And finally I was able to used it quite nice.
i think you have correct yout Project build target, and this how:
right click on your project folder in the package explorer->propreties->Android
then porject build target and choose you Android target (Android x.xx)
but before that you need to remove import android.R;

unable to instantiate application - ClassNotFoundException

EDIT: This problem has not already been resolved in the other suggested SO question
I had a fully working app on the market for over a year, with very few crash reports. Then recently I changed my app into a library, so that it could be included within multiple different "wrapper" projects. This was so that I could easily make different version - free, paid, non-google markets, with/without in-app purchasing etc etc.
The new "library+wrapper" app appeared to work fine. I could run it multiple times, without error. But then a day later (when presumably the OS had closed some or all of the app's activities) I tried to run it and it reported
Unable to instantiate application com.mycompany.mygamelibrary.MyGameApplicationClass: java.lang.ClassNotFoundException: com.mycompany.mygamelibrary.MyGameApplicationClass
The class it failed to find is the first class that runs when the program starts up, MyGameApplicationClass - which extends Application. This class is part of the library.
I suspect something goofy in one of the two manifest files.
The manifest of the wrapper project contains the lines...
<application android:icon="#drawable/mygame_icon"
android:screenOrientation="portrait" android:label="My Game Name"
android:name="com.mycompany.mygamelibrary.MyGameApplicationClass">
Any ideas what could have gone wrong?
EDIT: The library was referenced "the correct way" as defined by yorkw's answer to this SO question.
EDIT: I can not repeat the crash at the moment :-( I don't know what it is the OS does when the app is not used for a day or two.
There are two possibilities. Either you, like me, have a spelling error in your manifest file. Have a co-worker or friend read it to make sure the name is correct. Or you have not referenced the project correctly.
The official document describes how to properly link projects in its documentation.
Why it would first seem to work and later stop working is a bit of a mystery. However, I guess that the VM might still have had the necessary references ready to resolve the classes in the library just fine. A restart of the VM removed all those references and trying to resolve them was unsuccessful.
Update: Regarding the edits in the OP: As you confirm that you have correctly referenced the other project, you can check if the project is included in APK, just to be sure. You can rename and open an APK as any other archive (.rar works fine for me). Sometimes, it happened to me, the project is not correctly included in the APK. A cleaning of your workspace usually remedies the problem and so could a restart of your IDE depending on what you are using. To manually conduct a clean in Eclipse for example, use Project->Clean... or try Android Tools->Fix Project Properties by right-clicking on your project.
As you seem to also have fixed the problem by restarting your device, it could be that the libraries were linked incorrectly. A problem that I have never seen myself but as a very common quote says: "Have you tried turning it off and on again?".
For Android Studio:
Build --> Clean Project
Fixed issue.
Have you tried to make a new subclass of MyGameApplicationClass in your 'main' project and set it in the manifest as Application class?
I had a slew of bugs with Android Studio 3.0 Canary 4 and the way I fixed them was by editing the AndroidManifest.xml by adding in some jibberish to the application name. Then, I clicked build. Obviously, a whole mess of new error messages appeared. I changed the name back to what it should be, built the app, and it just ran.
Sometimes, I just don't know...
EDIT: Just ran into this issue on Android Studio 3.0 Canary 4 on my laptop when switching over. I again went through the same process of changing AndroidManifest.xml file to contain a typo, building, and changing back. That didn't work.
I then noticed that instant run was still enabled. Going into settings (by clicking command + , (comma key)) and typing "instant run", I was able to disable instant run, built the app, and the error of class not found went away.
Summary of Steps to Fix [FOR ME]
Invalidate cache / restart
Clean the project
Manually delete the build folder (need to be in project view for this one)
Make an intentionally errant edit to your AndroidManifest.xml file, build the app, observe the errors, remove the errant edit and build again
Disable instant run
Again, I don't mean to insinuate that this will fix everyone's error, but I have now used some combination of these steps on two different machines (MacOS Sierra) and it has been resolved for me. Hope it helps.
In my case, application id and package were mismatched. This should be same as presented in following images...
AndroidManifest.xml
app/build.gradle
In this case you can see, applicationId and package both are same that is com.mycompany.mygamelibrary
May be its a Build Path Configuration problem.I did the following to solve the issue.
1.Right click on your project and go to Java Build Path.
2.Click on Order and Export tab.
3.Check Android Private Libraries and other 3rd part libraries if you have added.
4.Press ok and clean the project.
I hope it will solve the issue.
Once I had the same error message, but maybe the cause isn't the same.
I did a code and worked for a while, then I wanted to improve it and got the same error and I couldn't run it.
I could fix the problem with
the correct Build Path order (as I can see you've already did this)
I check on the Order and Export tab the android-suppor-v4.jar
and the key was the Android SDK Managert->Upgrade everything and (next) Eclipse->Help->Check for updates.
After I upgraded to the latest android plugin and SDK my app compiled and ran again.
I hope this will help you!
I'm not very sure about this but it might be that your system's debug.keystore license validity has expired as it is valid for only 365 days. You just need to delete the debug.keystore from your computer. The debug.keystore will be generated automatically by Eclipse when you compile your Android App.
Same message seen ... this time it turned out to be different output folders for MyApp/gen and MyApp/src in the Build Path (caused by Maven integration).
Unchecking "Allow output folders for source folders" solved the problem.
I had this issue in an Android application that needed an Application class which was created in wrong path inside the Android Studio project. When I moved the class file to the correct package, it was fixed.
This all Process work for me to solve application class Exception.
Step 1: Open Run(window+R) Search -> Prefetch Remove all file (Some file not Delete)
Step 2: Open Run(window+R) Search -> %temp% Remove all file (Some File not Delete)
Step 3: Open Android Studio -> Build -> Clean Project
OR
Select File > Invalidate Caches / Restart > Invalidate and Restart from Android Studio toolbar.
OR
Close and reopen Android project.
OR
Restart System
I ran into this issue several times and both times it seemed to be caused by some instant run feature.
In my case, deleting the application from the device and then installing it from Android Studio again resolved the issue.
I ran into this problem today. The project runs well for over a year but today it reports this issue, and cannot debug on my testing device.
I fixed it by updating to latest gradle version. Hope this can solve your problem.

Eclipse opens wrong source file on exception

I have several Android projects in an Eclipse workspace:
a stand-alone application project with a class my.package.Foo
a library project with a different class my.package.Foo
two application projects that depend on the library project and contain no source code
The problem comes when working with one of the applications built on top of the library project. When it crashes (sadly, a frequent occurrence), I double-click on a line of the stack trace in the logcat to go to the relevant source. The problem is, if the line is for Foo.java, Eclipse always opens the source from the stand-alone project. The only way I can direct Eclipse to the right source is to close the stand-alone project, which is somewhat inconvenient.
Is there any way to get Eclipse to pay attention to which application actually crashed when it looks for the relevant source file? I assume that this is some sort of classpath problem (similar to that described in this post). However, I don't see anything in the Android run configuration properties for modifying the class path. Eclipse always seems to run through the workspace projects in alphabetical order by name and opens the first my/package/Foo.java it finds.
I'm using the latest Android ADT and SDK versions.
Per the link provided in the comment by #blessenm, this is an issue with logcat in Eclipse. We should see a fix in Release 20 of the SDK tools. As can be seen here, the patch that fixes it has been completed and is in line for final approval.
Meanwhile, the best thing to do is to change the logcat preferences (Window -> Preferences -> Android -> LogCat) so that the double-click action is "Go to Problem (method declaration)" instead of the default "Go to Problem (error line)". This isn't foolproof: it will at least open the file but if there are multiple methods with the same name, it will go to the first method, regardless of signature. (When the fix is incorporated, there will be no need for options for double-click action and it should disappear from the preferences.)

Categories

Resources