Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building fails when res /layout folder is not empty #447

Closed
kfrajer opened this issue Mar 5, 2018 · 4 comments
Closed

Building fails when res /layout folder is not empty #447

kfrajer opened this issue Mar 5, 2018 · 4 comments
Labels

Comments

@kfrajer
Copy link
Contributor

@kfrajer kfrajer commented Mar 5, 2018

I was able to set xml layouts under res/layout folder in previous versions of Android mode. I am currently running AM 4.0.1 in P3.3.6 and Win10x64.

The issue is this. I have a data folder where I have my images. I also have a res>>layout folder and inside there is one xml file. When I try to build the app, I get an error that tells me Gradle fail to merge. I have attached the error message as a text file as this error is very verbose and I cannot get to capture the heading of it. I used to be able to do this before when apps were built with ant. I have an app that uses layout in xml and while I can go back to an older version of AM, it would be great to include this capability.

Error file: gradle_Error.txt

Kf

@codeanticode

This comment has been minimized.

Copy link
Member

@codeanticode codeanticode commented May 22, 2018

I added a res/layout folder with one xml file in it to a test sketch, and have not experience any build errors. What are the layout files you are including in your sketch?

@kfrajer

This comment has been minimized.

Copy link
Contributor Author

@kfrajer kfrajer commented May 26, 2018

Hi Andres

So I was trying to reproduce the problem and I was able to solve it myself. I was having the error as listed above. I did some research and these are my findings:

The manifest file at the root level of my Processing folder has a field package="". I have included my own support layout in res/layout. When the code is built, I found that the manifest file in the temp folder is package="processing.test.inflatordemo". To proper inflate, I need to do this:

fl = (FrameLayout)act.findViewById(R.id.content);
LayoutInflater inflater = getActivity().getLayoutInflater();
final View inflator = inflater.inflate(processing.test.inflatordemo.R.layout.scrollview_images, null);
sv = (ScrollView)inflator.findViewById(processing.test.inflatordemo.R.id.sv_image);
fl.addView(sv);

Now my scrollView is displayed. For completion, here is my test layout:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/sv_image">

  <LinearLayout
        android:id="@+id/layout_vsv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
	android:focusable="true"
	android:clickable="true">
      

      <!-- things to scroll -->
      <ImageView
	android:id="@+id/img_pic1"
        android:src="@drawable/pic1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="center"
        android:background="#FFFFBB33"/>
    </LinearLayout>
</ScrollView>

When I did this in my prev life, Android Mode was being built with ant. Now in android mode v4.0 this should do the trick. You can close the issue and I hope this is good documentation of implementation xml layouts for PDE users.

Kf

@codeanticode

This comment has been minimized.

Copy link
Member

@codeanticode codeanticode commented Jun 17, 2018

@kfrajer thanks for the update!

The manifest file in the sketch is used as a template to generate the actual manifest in the build folder, only then it is filled out with the correct package string. The idea is that you can set your own package name if you want to (it is actually required if you are exporting the sketch as a signed app). But maybe is better if the default package name ("processing.test.sketch_name") is set in the sketch's manifest.

@kfrajer

This comment has been minimized.

Copy link
Contributor Author

@kfrajer kfrajer commented Jun 25, 2018

maybe is better if the default package name ("processing.test.sketch_name") is set in the sketch's manifest.

Yes, that could work if this is automated. In case the sketch name is changed, would you do a check to compare the manifest's package name and the sketch current's name and, if they differ, would you re-generate this file? This is minor. It happens I do most of my testing in temp sessions in Processing and these files do change name so I have noticed.

Kf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.