• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Android Code doesn't compile, Android Studio 3.0.1

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Here's the error it gives while i try to compile the code:-

Information:Gradle tasks [:app:assembleDebug]
G:\SOURCE_CODE\DynamicUI\app\src\main\res\layout\activity_main.xml
Error:(17) error: mismatched tag.
Error:(17) mismatched tag.
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Information:BUILD FAILED in 10s
Information:4 errors
Information:0 warnings
Information:See complete output in console

and here's the event log for the app:-
30-01-2018

14:52 * daemon not running; starting now at tcp:5037

14:52 * daemon started successfully

14:53 Executing tasks: [:app:assembleDebug]

14:53 Gradle build finished with 4 error(s) in 10s 347ms

Here is the original source code from where i got this tutorial:-

Android Fragment Transaction(One Activity|One container With Multiple Fragment)


or

https://github.com/hdpavan/FragmentTransaction

Here is my code for building a dynamic UI with fragments in android studio:-

https://gist.github.com/pamnanaimanish169/b18b0ae500fddf95c0dd53e337337ce5

Here is the screenshot of the android studio:-
"screenshot_error.jpg"

Machine Enviornment:- Windows 10(64-bit)

I tried executing the app but it shows the error log and does't even open android emulator.

Android emulator:-Nexus 4 API 21

"screenshot_avd.jpg"

All the necessary files are uploaded as attachments

screenshot_error.jpg
[Thumbnail for screenshot_error.jpg]
Screenshot error
screenshot_avd.jpg
[Thumbnail for screenshot_avd.jpg]
AVD screenshot
 
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post full activity_main code ? The code in Github is different with the code in screenshot_error.jpg
 
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From that image you have a tag that is closed and then you add a close tag for it.
eg:
<myTag someAttr="foo"/>
</myTag>

 
Ranch Hand
Posts: 84
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Delete line 17:


As Dave has already suggested, you've already closed it on line 15 with />

 
Manish Pamnani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Joe wrote:Can you post full activity_main code ? The code in Github is different with the code in screenshot_error.jpg



Here is the screenshot of the activity_main.xml:-

"activity_main.xml"

All the required files are sent as attachments
screenshot_activitymain.jpg
[Thumbnail for screenshot_activitymain.jpg]
 
Manish Pamnani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Adam Wentz wrote:Delete line 17:


As Dave has already suggested, you've already closed it on line 15 with />



Yes, that was one of the problems and it worked out great!!
Thanks for replying!!
 
Manish Pamnani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:From that image you have a tag that is closed and then you add a close tag for it.
eg:
<myTag someAttr="foo"/>
</myTag>



Yes it seems to have solved one of my problems and thanks for the reply!!
But can you look further into it and see more errors that i have got!!
I have posted the screenshot of activity_main.xml for further refrence!!
It would be nice to hear from you!!
 
Saloon Keeper
Posts: 7582
176
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't post screenshots of text - post the actual text instead. That makes it much easier to read, quote and copy.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Manish Pamnani wrote:

Yes it seems to have solved one of my problems and thanks for the reply!!
But can you look further into it and see more errors that i have got!!
I have posted the screenshot of activity_main.xml for further refrence!!
It would be nice to hear from you!!



You'll need to post the errors and (as Tim says) paste the xml here in code tags.
It's not easy to trawl through a file manually looking for errors when there are tools (eg the compiler) that tell you what the errors are.
 
Adam Wentz
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the other error you're referring to is the AAPT2 exception, that is a plugin that is used by Android Studio when you're using Gradle 3.0. If you're having problems with it, you can always revert to the previous version.

I had to do so recently, myself, while tinkering with an older project.

Add:



in your gradle.properties.

Although, truth be told, you may want to also dig in deeper to the problem at hand since that particular plugin is quite important to the new Android Studio environment.
You can read more about it here: About Android Plugin for Gradle 3.0.0
 
Manish Pamnani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Joe wrote:Can you post full activity_main code ? The code in Github is different with the code in screenshot_error.jpg



Here is the full "activity_main.xml" code



Thanks for replying!!
 
Manish Pamnani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Adam Wentz wrote:If the other error you're referring to is the AAPT2 exception, that is a plugin that is used by Android Studio when you're using Gradle 3.0. If you're having problems with it, you can always revert to the previous version.

I had to do so recently, myself, while tinkering with an older project.

Add:



in your gradle.properties.

Although, truth be told, you may want to also dig in deeper to the problem at hand since that particular plugin is quite important to the new Android Studio environment.
You can read more about it here: About Android Plugin for Gradle 3.0.0



Yes you are quite right and i did as you said but it didn't solved any of my problems, but thanks for replying!!!
 
Manish Pamnani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:Please don't post screenshots of text - post the actual text instead. That makes it much easier to read, quote and copy.



Thanks, i will keep that thing in mind next time i post something.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic