To release my game to google play more conveniently, I have transform my release format from apk to aab. I follow the google document exactually at https://developer.android.com/guide/playcore/asset-delivery/integrate-java. I created an AssetPack and move some resource files to the assets direction. for example, I have one test.png in asset-pack-name/src/main/assets/test.png.
Then I build to an aab file, and run the game on my device. When I invoke
display.newImage(group, test.png)
and throw an error that canāt find the test.png resource.
I think you need to specify the path to the folder where the image is located. Only I donāt remember how to do it)
Are you trying to build on native environment? If not, you should refer directly to the Solar2D documentation, not Android. AAB file is automatically generated with Solar2D and you donāt need to do something special for your code to work.
I canāt get resources in Lua after using assetpack. I can only copy resources to documents directory on Android
How to copy resources to documents directory, after install the aab to device, whereās the resource directory of assetpackļ¼I test the follow code local pngPath = system.pathForFile("InstallTime/test.png", system.ResourceDirectory)
, run the code and get the pngPath is .corona-plugins/InstallTime/test.png
, but how to reach .corona-plugins ?
I made a copy on Android, which should be wrong. After copying, the resources will double
androidļ¼
CoronaActivity activity = CoronaEnvironment.getCoronaActivity();
File file1 = CoronaEnvironment.getDocumentsDirectory(appContext);
AssetManager assetManager =appContext.getAssets();
copyAssetsFiles(assetManager,āassetsā,file1.getAbsolutePath()+"/assets");
public static void copyAssetsFiles(AssetManager assetManager, String mAssetsPath, String mSavePath)
{
try
{
String[] fileNames=assetManager.list(mAssetsPath);
if(fileNames.length>0)
{
// č„ęÆē®å½
for(String fileName:fileNames)
{
String newAssetsPath="";
if((mAssetsPath==null)||"".equals(mAssetsPath)||"/".equals(mAssetsPath))
{
newAssetsPath=fileName;
}
else
{
if(mAssetsPath.endsWith("/"))
{
newAssetsPath=mAssetsPath+fileName;
}
else
{
newAssetsPath=mAssetsPath+"/"+fileName;
}
}
copyAssetsFiles(assetManager,newAssetsPath,mSavePath+"/"+fileName);
}
}
else
{
//Log.d("Fileļ¼"+mSavePath);
File file=new File(mSavePath);
if(!file.exists())
{
file.getParentFile().mkdirs();
java.io.InputStream is= assetManager.open(mAssetsPath);
java.io.FileOutputStream fos=new java.io.FileOutputStream(new File(mSavePath));
byte[] buffer=new byte[1024];
int byteCount=0;
while((byteCount=is.read(buffer))!=-1)
{
fos.write(buffer,0,byteCount);
}
fos.flush();
fos.close();
is.close();
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
I explore all over the Solar2D document, but canāt still find the file about automatically generate to AAB file. though I have to do something on native environment, but can still refer to the related document, can you send me the document url ?
Iām sorry if Iām misunderstanding things here. Also, it may be a good idea to propose a simple change to the documentation that building for Android also generates an .aab
file which is the one you should upload to Google Play. You donāt need to change anything in your code for that.
-- let's say you have img.png file under assets folder
local img = display.newImageRect("assets/img.png", 100, 100)
-- https://docs.coronalabs.com/api/library/display/newImageRect.html
If you are looking to replace OBB
with Play Asset Delivery
, this is not yet supported but probably, will be available later this year as Vlad stated here - Solar2D First Anniversary!
Just to clarify, ānext yearā means next year for solar2d. Asset Delivery is basically next feature iām working on.
Now that itās not support for display.newImage()
the images of Asset Pack. Is there a replace solution to display the images, rather than invoke the interface display.newImage()
?
Are you trying to use expansion files? Do you have huge files that needs downloading? From what I read in your first post, I thought you were just trying to switch from .apk
to .aab
. Anyway, if you are looking for expansion files, you can use .obb
format for now.
Thanks, I would take it into account. But for the google policy:
From August 2021, new apps will be required to publish with the Android App Bundle on Google Play.
We have a new game in develop plan to release on Google Play, and wouldāt be finish before August this year. so worry about it would be rejected by google if use in .obb format.
Thereās not much I can do to speed up the process but maybe you can upload an earlier version of your game with .obb and publish it to internal channels so Google Play would treat it as an old application. Not entirely sure if this would work but you could try.