Using provided scope with Android Studio and Gradle (0.5.8+ only) - android

Using provided scope stopped working in android studio 0.5.8 for java modules.
For example, my Java module uses some classes that are required from Android...(bad I know, but issue exists with any kind of provided lib). Project compiles and runs fine but IDE shows provided classes as red:
Everything worked fine before 0.5.8 of android studio.
Intellisense does not work anymore....I feel like a savage coding without autocompletion
Filed a bug, where you can see details of the gradle file https://code.google.com/p/android/issues/detail?id=69481&thanks=69481&ts=13996519231
I want to believe this is a common setup, has anyone run into this and come up with any solutions?

Related

Can not install MvvmCross 9.0.9 (.NET6) creating a new android project in VS2022

I'm trying to install MvvmCross 9.0.9 for a new beginner project, reading the steps for TipCalc tutorial and used the newest version of it (https://github.com/MvvmCross/MvvmCross-Samples/tree/master/TipCalc), which works fine. But if I try to install MvvmCross package for brand new project with NuGet it says this
or if I add the reference to XXX.Core it gives me:
Warning Project '..\XXX.Control.Core\XXX.Control.Core.csproj' targets 'net6.0'. It cannot be referenced by a project that targets 'MonoAndroid,Version=v12.0 .
For XXX.Core there is no problem installing MvvmCross. Can anyone tell how to set up a new project without this behavior? I don't know what exactly I could have overlooked.
First I created a new .Core project with .NET6 library class as in the tutorial mentioned and installed MvvmCross package, added ViewModels etc.. No problems here. Then added the .Droid Xamarin project (Blank App). Everything step by step. After getting error, I tried different target frameworks changed here and restarted VS and rebuild. Still same behavior.
Unfortunately I haven't been able to find much about it here and as a newcomer to MvvmCross/Xamarin I also have difficulties finding current examples or tutorials for the latest version, so I welcome any help.
Just as the message said, the MvvmCross 9.0.9 is support the .net6.0 not the .NetFramwokr and MonoAndroid which the xamarin.android used.
So if you want to use the MvvmCross nuget package in the Xamarin.Android project, you need to use the lower version which supports the .NetFramwokr and MonoAndroid. Such as the MvvmCross 8.0.2.
You can also try to migrate the xamarin.android project to the .net 6.0 according to this document about Migrating Xamarin.Android Applications to .NET 6. And then you can install the MvvmCross 9.0.9 in the migrated project.
In addition, you said:
No problems here. Then added the .Droid Xamarin project (Blank App). Everything step by step. After getting error, I tried different target frameworks changed here and restarted VS and rebuild
I can't understand what does the added the .Droid Xamarin project (Blank App) mean. But you can create a new .net core app which target framework is .net 6.0. Such as:
And then copy the code and file in your old project to this new project. After this, you can also use the MvvmCross 9.0.9 in it.

Program type already present: android.support.annotation.AnimRes

This problem happened to me after i updated to the latest version of Xamarin.Forms (4.6.0)
I get this error whenever i try to build my Android Projects in Visual Studio For Mac (8.5.4)
What i tried so far:
Using different versions of the Android Support libraries
Cleaning my NuGet Cache
Reinstalling the SDK
Cleaning, Rebuilding, Restarting VS (several times)
Oddly i managed to get it working for a few builds after changing my support library versions from 28.0.0.3 to 28.0.0.1 manually in the csproj file. However i tried this several times and it doesn't solve the problem.
The problem occurs if i create a fresh Xamarin.Forms project aswell.
Any advice appreciated, as this is starting to be frustrating.
I don't know if this will help, but you should migrate to AndroidX as soon as possible, nevertheless. Xamarin has migrated to them, starting from Forms 4.5
Here is some more information about the libraries - Introducing AndroidX for Xamarin
There is a special NuGet package for the migration - Xamarin.AndroidX.Migration. Also available is a built-in functionality in Visual Studio - here
What I can suggest is you try to migrate to AndroidX libraries, since the old support libraries won't be supported from now on, and you will surely encounter some issues if not like this one, then something else will pop-up in the future.

How to get IntelliJ IDEA 14 working with Scala on Android (SBT)

I'm using android-sdk-plugin to make Android apps with Scala using SBT. This generally works great - however when trying to import the project into IntelliJ IDEA 14.1 the imported project looks rather empty and does not recognize my source files as being part of the project.
The documentation says:
IntelliJ 14 now includes native support for importing projects from android-sdk-plugin. The process generally works well, however there are still several caveats:
The idea-sbt-plugin is still required to actually perform the build (no longer necessary as of IDEA 14.1)
Cloning and importing even the simplest example project results in an empty IDE not showing any sources at all:
I have installed both the Scala plug-in and the SBT plug-in (which I believe should no longer be required) as requested by the documentation.
What essential step am I missing?
Edit: I added the plug-in manually to project/plugins.sbt, then ran gen-android to get a project/build.scala containing object Build extends android.AutoBuild.
The essential step missing is the Android plug-in of IDEA. This might seem obvious but in contrast to plug-ins for other frameworks this one does not just provide extra goodies but is actually essential for anything Android.
Having the plug-in installed allows for selecting Android as a Project SDK (which not just selects an Android SDK but also a Java SDK to go with it).

Unit tests in Android Studio 0.8

BREAKING NEWS: Android Studio 1.1.0 now has built-in support for unit testing. See more here: https://sites.google.com/a/android.com/tools/tech-docs/unit-testing-support
At first I know that there are very, very, very much similar questions (even here on SO). Most of them are terribly outdated so I'm asking a fresh new question which should be up to date for Android Studio 0.8.x.
I know there are some libraries which work somehow, but in almost each case I had no evidence that the information were up to date. I know there is e.g. roboelectric, there are also some deprecated Jake Wharton like gradle-android-test-plugin or double-espresso, I also found the library RoboSpock and Deckard. But none of them seems to have any Android Studio integration.
After long reseach I found this two bugs in all implementations:
The classpath is broken and needs to been hacked to get junit running
The junit tests cannot been debugged
What I'm looking for:
I want to automatically test an algorithm (which is plain java)
I want to check the integration in my Android app works
I want an integration in Android Studio so that I can jump into the code out of a stacktrace
I want to step thrue the test code
I found also somewhere a nice hack which run the tests in gradle as an external task and pushed the results into AS so that the results could been displayed, but unfortunately I cannot find that link again (and if I remember correctly it did also not work for me).
Do you guys have some fresh references? Does it work for you?
You have to edit the .iml file that Android Studio generates to point to your test-classes directory and also to fix the Stub error from Junit. There is currently no work around for this.
Gradlectric is a sample that uses the Robolectric Gradle Plugin to run unit tests in Android Studio.
Here you miss one example project setup https://github.com/nenick/android-gradle-template
But none of them seems to have any Android Studio integration.
This project is maintained for android studio
The classpath is broken and needs to been hacked to get junit running
gradle scripts will fix the classpath
The junit tests cannot been debugged
tests a running inside AS so they are easy to debug
This project of mine does not cover all your requests, but a fair lot of them.
It covers a default Java test case, and some tests interacting with Views.
The root project uses Travis CI, which uses gradle connectedCheck to run the tests. To be able to debug the tests, you can just create a test run configuration in AS and run it in debugging mode.
Note that this does not use any special Android testing frameworks like robolectric.
You can find a fork of Jake Wharton's gradle-android-test-plugin here. This is compatible with AS 0.6 and is regularly maintained by Robolectric. You can look at this project to set up Robolectric in Android Studio with help of this plugin. You can achieve fair bit of functionality you mentioned with the help of robolectric-gradle-plugin. You can also successfully debug your test code using AS.

RequestFactory Interface Validation issue

I'm using RequestFactory in an Android Connected AppEngine project with a shared folder. The Eclipse AnnotationProcessor (that does the interface validation) works fine for the AppEngine project, but does not generate the MyRequestFactoryDeobfuscatorBuilder.java class for the Android project. It seems it does not do anything when I build the project. My project properties are like described in http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation.
Now my question: how can I obtain any information why the Interface Validation is not working? There is nothing in my logs or under "Problems".
I had the same problem - both projects were set up as per the link you provided.
I fixed it by changing the compiler version of BOTH the app engine and the Android project to 1.6.
The app engine was 1.4 when I imported it and I changed it to 1.6 (even though the workspace is set to 1.6). It didn't start working until I changed the compiler version of the Android project though. It was automatically set to 1.5.
Good luck

Categories

Resources