I am using the Unity engine to generate an android studio project.
My main project's main activity has the following code in its NativeActivity class:
return mUnityPlayer.injectEvent(event);
Everything compiles and works fine.
However, when I add a certain 3rd party library (androidNative) as a module
I get the following error when I try to compile :
Error:(86, 89) error: cannot find symbol method injectEvent(MotionEvent)
This is surprising, because it is an error in a file from the original project (not the module I added) and I only added a reference.
What is the reason behind this scenario? How can adding a module as a dependency of a project cause a file in the original project to not compile?
Related
I'm trying to use jdk.crypto.cryptoki/sun.security.pkcs11.wrapper.PKCS11 in IntelliJ, but for some reason it keeps throwing errors. It seems like it's unable to detect this package. One of the solutions was to add --add-exports jdk.crypto.cryptoki/sun.security.pkcs11.wrapper=ALL-UNNAMED in the settings, which I did, but now it throws a compile time error in the IDE:
Error:(5, 20) java: package sun.security.pkcs11 is not visible
(package sun.security.pkcs11 is declared in module jdk.crypto.cryptoki, which is not in the module graph)
I'm using Java 11. It works fine when I try to compile and run it over the terminal
This question already has an answer here:
Migrate resource files to Androidx
(1 answer)
Closed 3 years ago.
I've have recently migrated my app to AndroidX, blindly without knowing the ins and outs. As a result every time I run the project, it gives me a load of errors.
I have updated all my Gradle Dependencies and targetSDK to the most recent version code. I have also added the following to gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
But this has still made no difference.
Some of the following are examples of errors I am getting:
error: package android.support.annotation does not exist
error: package android.support.v7.widget does not exist
error: package RecyclerView does not exist
error: cannot find symbol class FragmentActivity
error: cannot find symbol class CardView
error: cannot find symbol class FragmentPagerAdapter
error: cannot find symbol class DialogFragment
I would just like to know I can get rid of these errors, as it is stopping me from running the project on my mobile device?
Here you can find the full class mapping.
In your case you have to change the imports:
error: package android.support.annotation does not exist
error: package android.support.v7.widget does not exist
Packages:
package androidx.annotation.*;
package androidx.appcompat.widget.*;
Classes:
android.support.v4.app.FragmentActivity androidx.fragment.app.FragmentActivity
android.support.v7.widget.CardView androidx.cardview.widget.CardView
android.support.v4.app.FragmentPagerAdapter androidx.fragment.app.FragmentPagerAdapter
android.support.v7.app.AppCompatDialogFragment androidx.appcompat.app.AppCompatDialogFragment
android.support.v7.widget.RecyclerView androidx.recyclerview.widget.RecyclerView
You seem to have everything set up correctly in your gradle file. The problem is that there are missing packages that have not yet been converted/migrated to AndroidX. Here's a little trick you can do:
Go to your app.gradle file and right-click anywhere.
Select Refactor on the menu that pops up.
In the sub-menu, select Migrate to AndroidX
Sit back and let Android studio migrate all your files.
To learn more, check this out.
I hope this helps. Merry coding!
In the Android Studio menu go to Refactor and select Migrate to AndroidX.
Rest the android studio will automatically do.
Other than this if you still find the error then you will have to manual perform certain task.
In the layout find all the old one and replace it like
android.support.v7.widget.CardView
with
androidx.cardview.widget.CardView
you will find the mapping related information here https://developer.android.com/jetpack/androidx/migrate/class-mappings
just find the old text by using Ctr+F and copy the replacement text
In the app build
implementation 'com.android.support:cardview-v7:28.0.0'
with
implementation 'androidx.cardview:cardview:1.0.0'
you will find mapping related information here https://developer.android.com/jetpack/androidx/migrate/artifact-mappings
I am creating Xamarin bindings on a AAR file in Visual Studio. I have created the bindings in Visual Studio using auto-generated code in an Android Bindings Library (Xamarin) project template. The bindings project compiles without errors and the only warnings in the build output relate to this specific issue: "The member '...' does not hide an accessible member. The new keyword is not required."
The problem is when I try to reference the bindings project. I created a blank Xamarin Android app project, called AndroidTest, which and ran fine. I then added a reference to the binding project to Android test. I added no code in AndroidTest that references the binding. When I build the AndroidTest project, I get the following error:
Error The "LinkAssemblies" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'AndroidTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'AndroidTest.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() AndroidTest
The bindings project has no reference to AndroidTest, and there are no other projects in the solution. How do I resolve this error?
I'm developping a Xamarin Android app and i'm facing a problem which seems to be a problem of nugget package dependencies :
Microsoft.Office365.OAuth.Xamarin V1.0.21
Dependencies :
MonoAndroid, Version v2.2
Xamarin.Android.Support.V4 V23.3
Dependencies :
MonoAndroid, Version v7.0
Whenever I try to build my project :
error: cannot find symbol android.support.v4.content.Loader.OnLoadCanceledListener
This error come from this java file
<%Project%>\obj\Release\android\src\mono\android\support\v4\content\Loader_OnLoadCanceledListenerImplementor.java
package mono.android.support.v4.content;
public class Loader_OnLoadCanceledListenerImplementor
extends java.lang.Object
implements
mono.android.IGCUserPeer,
// this line is making the build fails
android.support.v4.content.Loader.OnLoadCanceledListener
...
...
Morever, these packages work perfectly when they aren't added together.
Am I doing something wrong ?
I have a Cordova app several years old, which has capital letters in its package name.
It was working well before, with older versions of Cordova and building in Eclipse.
Now I cannot build it with Cordova 6.1.1 and gradle. It gives errors.
I have detected that it doesn't create the folder structure and files for the app class at src folder. It should create PackageFirst folder, then inside it PackageSecond since package name is PackageFirst.PackageSecond
I generated and copied those files myself. The cordova prepare command deletes the folder, so I run prepare and then copy the folder back in. Then I try compile. But it breaks again and the build doesn't succeed, with this error:
Here is my LogCat.
BUILD FAILED at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Caused by: com.android.dx.cf.iface.ParseException: class name (PackageFirst/PackageSecond/MainActivity) does not match path (packagefirst/packagesecond/MainActivity.class)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:520)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
I have been researching and the only solution I find, is that I need to make the package name all lowercase. Since this app is published at Google Play, I believe I cannot do that since it would be a different package name.
I have been able to build this perfectly for years until now.
Can anyone give me a solution to this problem that doesn't involve changing the package name? Thank you so much for any help!
EDIT:
I could get the package to build successfully, but it doesn't run on the device. With all the testing I had left uppercase in one place and lowercase in another. Once I fixed that, it built, but when trying to run it on the device, I get the following error:
Error: Failed to install apk to device: pkg: /data/local/tmp/android-debug.apk
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
Kindly name your packages in lower case. As I can see from error you posted above
com.android.dx.cf.iface.ParseException: class name
(PackageFirst/PackageSecond/MainActivity) does not match path
(packagefirst/packagesecond/MainActivity.cla ss)
the package names have different case. This might be a cause