Reputation: 75
When building my 2D mobile game (it is only a plane without anything on it yet) I get an error consisting of 5 exceptions all ending with Probably the SDK is read-only
These are the full exceptions:
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
Upvotes: 6
Views: 30611
Reputation: 2375
Definitely this problem can have a lot of root causes.
On my side, it was because my Windows username was not UTF-8 compatible.
I had this error :
(...)
stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
error: file not found: C:\Users\Sébastien\.gradle\caches\transforms-3\93e928d5c9a6ef082746c38777f64464\transformed\output\temp\module-info.java
Usage: javac <options> <source files>
use --help for a list of possible options
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':unityLibrary:compileReleaseJavaWithJavac'.
> Could not resolve all files for configuration ':unityLibrary:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: D:\Program Files\Unity\2022.3.28f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-32\core-for-system-modules.jar.
> Error while executing process D:\Program Files\Unity\2022.3.28f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\javac.exe with arguments {--system=none --patch-module=java.base=D:\Program Files\Unity\2022.3.28f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-32\core-for-system-modules.jar -d C:\Users\Sébastien\.gradle\caches\transforms-3\93e928d5c9a6ef082746c38777f64464\transformed\output\temp C:\Users\Sébastien\.gradle\caches\transforms-3\93e928d5c9a6ef082746c38777f64464\transformed\output\temp\module-info.java}
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
]
stdout[
Starting a Gradle Daemon, 1 incompatible and 4 stopped Daemons could not be reused, use --status for details
Exception while marshalling D:\Program Files\Unity\2022.3.28f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\32.0.0\package.xml. Probably the SDK is read-only
Exception while marshalling D:\Program Files\Unity\2022.3.28f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling D:\Program Files\Unity\2022.3.28f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-31\package.xml. Probably the SDK is read-only
Exception while marshalling D:\Program Files\Unity\2022.3.28f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-32\package.xml. Probably the SDK is read-only
(...)
You can read: error: file not found: C:\Users\Sébastien\
I changed the default Gradle configuration on my machine:
GRADLE_USER_HOME
with value E:\.gradle
Works!
Upvotes: 0
Reputation: 1
Please, delete ANDROID_HOME variable from environment variables if exists. (for any other development environment)
Upvotes: 0
Reputation: 566
After changing Minimum Api level 24 to 32....Now its Resolved....
File > Build Settings > Player settings > Player > other > Minimum API level 32
Upvotes: 1
Reputation: 1
Reimport all/Reopen Unity solved the problem for me. Right click in assets > Reimport All will clean the cache and this issue might go away.
Upvotes: 0
Reputation: 1
I encountered a similar issue with Unity Editor version 2021.3.9f1 and all other 2021 Unity versions while building the APK. However, after some troubleshooting, I found a workaround that might be helpful to others facing the same problem.
Solution:
I hope this information is helpful for others facing the same problem. Please let me know if you need any further details.
Upvotes: 0
Reputation: 149
I got the same error when trying to build an Android package for the first time.
The error message "Probably the SDK is read-only" was correct - everything under "C:\Program Files" is marked as read-only. I also noticed that the files in question, package.xml
, do not exist. What's happening is that Unity is trying to create them, and failing.
I ran the Unity Editor as Administrator (clicking through the stern warning "Unity is running as administrator which is unsupported") - make sure you don't have the Hub running, locate Unity.exe in File Explorer and run it as Administrator. I built the project and the package.xml
files were created! You only have to do this once; now that the files exist, you don't need to run Unity as Administrator any more.
Hope that helps!
Upvotes: 1
Reputation: 122
Along with this error, I was getting an error related to my apk signing. Although I was trying to generate a debug build, it should have picked up a default key.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':launcher:packageDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store "C:\Users\rohit\.android\debug.keystore": Invalid keystore format
But when I tried to generate a release build after creating a new signing key, even this error got fixed automatically.
Hope this helps someone facing both these errors together.
Upvotes: 0
Reputation: 155
For me, this issue went away when I fixed another error caused by duplicate library classes. I went to Assets/Plugins/Android, clicked on the culprit (in my case it was the "com.unity3d.ads.unity-ads-4.5.0" plugin and then unchecked Android as a selected platform for the plugin. After this, I was able to build.
Upvotes: 0
Reputation: 7
I tried several of these options and nothing worked. Selected "Developmental Build" and no errors!
Upvotes: 1
Reputation: 705
I ran into this same error when I was trying to target a different API Level than the one Unity came installed with. I had copied some android platform files from a separate SDK location, but when I tried to build I got that read-only error. So I removed those copied files and, under Preferences -> External Tools, I unchecked the option: Android SDK Tools Installed with Unity.
For me, that automatically selected the other Android SDK location I had tried to copy from. So the build worked for me after that, but you may need to select Browse to find the correct path to your SDK location.
Upvotes: 1
Reputation: 82
Try reading conversation in the forum
I think they have similar problems as yours. Maybe some of the solutions they mentioned might work for you. But have tried creating and building new unity project or building your previous projects? If it says read only then it's probably problems with permissions. Try opening unity with admin permissions.
If that won't work then try reinstalling unity using unity hub with android (unity + android). I once solved similar problem by doing this.
Hopefully I was helpful. Good luck.
Upvotes: 1