Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13075] Android:Module having images in assets folder installed in android application does not copy over assets during second build

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-08-29T19:16:18.000+0000
Affected Version/sRelease 3.0.0, Release 3.0.2
Fix Version/sn/a
ComponentsAndroid
Labelsexalture, supportTeam
ReporterRupesh Sharma
AssigneeEric Merriman
Created2013-03-15T13:14:40.000+0000
Updated2017-03-24T21:53:00.000+0000

Description

Description

In a custom android module having images in assets directory in which getting any image in Kroll.method using "context.getAssets().open("sample.jpg");" when installed to any blank android project it runs perfectly for the first time after cleaning it but again if try to install without cleaning it will not be able to find the file this time.

Steps to Reproduce

1. Create a Titanium Module Project and put any image in assets directory. 2. In "example" @Kroll.method put this code :
try {
    InputStream is = context.getAssets().open("sample.jpg");
    Log.d(LCAT, "inputstream=="+is);
} catch (IOException e) {
    e.printStackTrace();
}
3. Install this module in Titanium android project. 4. Clean the project and then install and run it.(It will run successfully this time) 5. Now install the project again without cleaning it first, and run it again.(This time it will not be able to find the file)

Error Logs

java.io.FileNotFoundException: sample.jpg
W/System.err(  957):    at android.content.res.AssetManager.openAsset(Native Method)
W/System.err(  957):    at android.content.res.AssetManager.open(AssetManager.java:315)
W/System.err(  957):    at android.content.res.AssetManager.open(AssetManager.java:289)
W/System.err(  957):    at ti.gl.imagemod.SampleimagemodModule.example(SampleimagemodModule.java:55)
W/System.err(  957):    at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
W/System.err(  957):    at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:140)
W/System.err(  957):    at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:289)
W/System.err(  957):    at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:166)
W/System.err(  957):    at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err(  957):    at android.os.Looper.loop(Looper.java:137)
W/System.err(  957):    at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)

Comments

  1. Chris Barber 2013-08-02

    Is this a emulator or device build? Is there a test project that demonstrates the problem?
  2. Rupesh Sharma 2013-08-02

    Hi Chris, Tested on device.
  3. Chris Barber 2016-08-29

    Unable to reproduce with Titanium SDK 5.5.0. Note that the steps to reproduce have changed. Now you must add the following imports:
       import java.io.InputStream;
       import java.io.IOException;
       import android.content.Context;
       
    and then change the test code inside your KrollModule implementation:
       @Kroll.method
       public String example()
       {
       	Log.d(LCAT, "example called");
       
       	try {
       		Context context = TiApplication.getInstance();
       		InputStream is = context.getAssets().open("test-asset.png");
       		Log.d(LCAT, "inputstream=="+is);
       	} catch (IOException e) {
       		e.printStackTrace();
       	}
       
       	return "hello world";
       }
       
    When testing, I see:
       [DEBUG] MymoduleModule: (main) [1,1431] inputstream==android.content.res.AssetManager$AssetInputStream@8edbfc7
       
  4. Lee Morris 2017-03-24

    Closing ticket as the issue cannot be reproduced.

JSON Source