Recent

Author Topic: Don't Compile and Run APK with Android Module Wizard  (Read 9533 times)

developing

  • New Member
  • *
  • Posts: 26
Don't Compile and Run APK with Android Module Wizard
« on: July 18, 2015, 10:57:41 am »
Hi all

I use install_tutorial_eclipse_users.txt file to setup and configure Lazarus IDE.

All things OK.
I install
  • Eclipse for Mobile Developers Version: Juno Service Release 2,
    install ADT Bundle ver: 23.0.6.1720515,
    Laz4android,
    Android Module Wizard Version 0.6 -  rev. 20 - 07 April 2015,
    NDK r10,
    Apache Ant ver.1.9.2 ,
    JDK ver 1.8.0.31,
    install and update SDK

Create an android project in eclipse like tutorial and import this into Lazarus IDE truly. Then put a "jTextView" component on form and Build that. Project compiled successfully.

When I use "Run--> [Lamw] Build and Run" menu to create APK Build error and show below message:

Code: [Select]
Building APK... : Exit code 1, Errors: 1
Buildfile: H:\Projects\Eclipse\workspace\Demo\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 24.0.2
 [checkenv] Installed at F:\android-sdk

-setup:
     [echo] Project Name: Demo
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 19.1.0
     [echo] Resolving Build Target for Demo...
[gettarget] Project Target:   Android 4.1.2
[gettarget] API level:        16
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: H:\Projects\Eclipse\workspace\Demo\bin\rsObj
    [mkdir] Created dir: H:\Projects\Eclipse\workspace\Demo\bin\rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for Demo...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [aapt] H:\Projects\Eclipse\workspace\Demo\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
     [aapt] H:\Projects\Eclipse\workspace\Demo\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
     [aapt] H:\Projects\Eclipse\workspace\Demo\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.

BUILD FAILED
F:\android-sdk\tools\ant\build.xml:653: The following error occurred while executing this line:
F:\android-sdk\tools\ant\build.xml:698: null returned: 1

Total time: 5 seconds
Panic: tool stopped with exit code 1. Use context menu to get more information.
Exception, Errors: 1
Fatal: [Exception] Failed: Cannot build APK!

Any solution?



« Last Edit: July 18, 2015, 10:59:42 am by developing »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #1 on: July 23, 2015, 02:45:12 am »
Hi developing!

Try change project  "AndroidManifest.xml" according your system installation....

change here:

Code: [Select]
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="17"/>

try other:   "android:targetSdkVersion"  [18 or 19 or 20 or 21 or 22]

It depends on what you system have installed!

Thank you!


Ps.

Remember:  Eclipse is not mandatory... please, read  "install_tutorial_Ant_users.txt", too.
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

developing

  • New Member
  • *
  • Posts: 26
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #2 on: July 23, 2015, 08:08:51 pm »
Hi

Thanks to Your answer.

I read install_tutorial_ant_users.txt and follow this tutorial, but show that error again.

Even I want use some demos to change and build, but this way doesn't any solution and show an error (in attached picture).

I use eclipse and create APK file easily. but cannot create an APK with lazarus yet.

I attach F:\android-sdk\tools\ant\build.xml file that has error for any solution.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #3 on: July 24, 2015, 01:11:04 am »
Hello developing!

Please, 

1.

Put here your "JNIAndroidProject.ini"     [ ...\laz4android\config ]

2.

You can change your project "bulid.xml" [NOT Ant 'bulid.xml" !!!]

Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
<project name="AppActionBarTabDemo2" default="help">
<property name="sdk.dir" location="C:\adt32\sdk"/>
<property name="target"  value="android-17"/>
<property file="ant.properties"/>
<fail message="sdk.dir is missing." unless="sdk.dir"/>
<import file="${sdk.dir}/tools/ant/build.xml"/>
</project>

Try the same "target" from your "AndroidManifest.xml"

Change here:

Code: [Select]
<property name="target"  value="android-17"/>

and here for Demo

Code: [Select]
<property name="sdk.dir" location="C:\adt32\sdk"/>

3. If you have an eclipse project, then you can try use it to build/run your Apk!

Your Project --->>Run As  ---> Android Application

4. Note: From Lazarus you need "Run" ---> "Build" to get your "controls.so" ...
    and then "refresh" your eclipse project ... before run it ...
« Last Edit: July 24, 2015, 01:19:28 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

developing

  • New Member
  • *
  • Posts: 26
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #4 on: August 03, 2015, 09:15:42 am »
Hi,

Sorry for late to reply.

My project "build.xml" and Laz4Android "JNIAndroidProject.ini" attached.

I cannot build APK in Lazarus yet, and error that write in first post existence. For deploy and build APK use Eclipse IDE.

When design project in lazarus, layout is OK, but when "Run As  ---> Android Application " in Eclipse and install output APK on a real android device (Samsung Galaxy S3) "jTextView"s, "jEditText"s, and "jButton"s are tumble like attached picture (after).

Pictures description:
before.jpg => That's mean before refresh project in Eclipse IDE (Design time in Lazarus IDE).
after.jpg    => That's mean after refresh and build project in Eclipse IDE, then back to Lazarus IDE.

note1: I changed margins property (bottom, top) for all of components, but this problem not solved.
note2: I changed "PosRelativeToAnchor" and "PosRelativeToParent" property, but this problem don't solved.

And a suggestion, for Right to left language like Persian, Arabic and Hebrew Add a BiDiMode property to change text directional like Standard Edit component.

Thanks.
« Last Edit: August 03, 2015, 09:24:47 am by developing »

developing

  • New Member
  • *
  • Posts: 26
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #5 on: August 03, 2015, 09:57:00 am »
Hi,

I even change Top property of components (Like below), but don't solve my problem and components keep their first position.

Code: [Select]
jButton3.  Top := jButton3.  Top + 50;
Thanks.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #6 on: August 05, 2015, 12:19:29 am »
Hello Developing!

What you need is do layouting based on "Anchor" and "PosRelativeToParent" and "PosRelativeToAnchor"

and dimension based on "LayoutParamHeight" and "LayoutParamWhidth"

[Top, Left, Whidth and Height ... etc [just designer vision], does not work on android "relative layout" model ...]

Edited: put here a "print screen" [what you want to accomplish]. I will do a layout example code!
« Last Edit: August 05, 2015, 12:32:48 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

developing

  • New Member
  • *
  • Posts: 26
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #7 on: August 05, 2015, 07:53:26 am »
Hi

Thanks to reply.

I want create a project that to show in device same design time. In the other words, I want my project components stay in design time places. Or is it possible change top, left, right and bottom of any components and my project layout in APK show like it in design layout?

For example: in real Android device like "before.jpg" picture "Save to database" button to be top of components then under this "Full name" label and etc like my design in this picture.

Thanks and sorry for my poor English.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #8 on: August 05, 2015, 03:37:28 pm »
Hello Devoloping!

Quote
.... my project layout in APK show like it in design layout...

Yes! But you need a little more work!

 You need  do layouting  based on "Anchor" and "PosRelativeToParent" and "PosRelativeToAnchor" and dimension based on "LayoutParamHeight" and "LayoutParamWhidth"

In Attachments you can see a "design time" picture and a "run time" picture

Here is the code

"Unit1.pas"

Code: [Select]
unit unit1;

{$mode delphi}

interface

uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
    Laz_And_Controls_Events, AndroidWidget;

type

  { TAndroidModule1 }

  TAndroidModule1 = class(jForm)
    jButton1: jButton;
    jButton2: jButton;
    jEditText1: jEditText;
    jEditText2: jEditText;
    jListView1: jListView;
    jTextView1: jTextView;
    jTextView2: jTextView;
    jTextView3: jTextView;
    procedure jButton1Click(Sender: TObject);
  private
    {private declarations}
  public
    {public declarations}
  end;

var
  AndroidModule1: TAndroidModule1;

implementation

{$R *.lfm}

{ TAndroidModule1 }

procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
   jListView1.Add('Name: '+jEditText1.Text);
   jListView1.Add('Number: '+jEditText2.Text);
end;

end.

"Unit1.lfm"

Code: [Select]
object AndroidModule1: TAndroidModule1
  Left = 306
  Top = 64
  Width = 320
  Height = 573
  MarginLeft = 0
  MarginTop = 0
  MarginRight = 0
  MarginBottom = 0
  Text = 'AndroidModule1'
  ActivityMode = actMain
  BackgroundColor = colbrDefault
  object jTextView1: jTextView
    Left = 74
    Top = 5
    Width = 171
    Height = 20
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    PosRelativeToAnchor = []
    PosRelativeToParent = [rpTop, rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'App Developing Data Demo1'
    Alignment = taLeft
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    TextTypeFace = tfNormal
    FontSizeUnit = unitDefault
    Id = 1827166
  end
  object jTextView2: jTextView
    Left = 5
    Top = 35
    Width = 61
    Height = 20
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'Full Name:'
    Alignment = taLeft
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    TextTypeFace = tfNormal
    FontSizeUnit = unitDefault
    Id = 8651431
  end
  object jEditText1: jEditText
    Left = 5
    Top = 70
    Width = 310
    Height = 39
    MarginLeft = 5
    MarginTop = 10
    MarginRight = 5
    MarginBottom = 10
    Visible = True
    Anchor = jTextView2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    Text = 'jEditText1'
    Alignment = taLeft
    InputTypeEx = itxText
    MaxTextLength = -1
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    HintTextColor = colbrSilver
    ScrollBarStyle = scrNone
    MaxLines = 1
    HorScrollBar = True
    VerScrollBar = True
    WrappingLine = False
    Editable = True
    FontSizeUnit = unitDefault
    Id = 8921191
  end
  object jTextView3: jTextView
    Left = 5
    Top = 124
    Width = 99
    Height = 20
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jEditText1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'Contact Number:'
    Alignment = taLeft
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    TextTypeFace = tfNormal
    FontSizeUnit = unitDefault
    Id = 2728698
  end
  object jEditText2: jEditText
    Left = 5
    Top = 159
    Width = 146
    Height = 39
    MarginLeft = 5
    MarginTop = 10
    MarginRight = 5
    MarginBottom = 10
    Visible = True
    Anchor = jTextView3
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpHalfOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'jEditText2'
    Alignment = taLeft
    InputTypeEx = itxText
    MaxTextLength = -1
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    HintTextColor = colbrSilver
    ScrollBarStyle = scrNone
    MaxLines = 1
    HorScrollBar = True
    VerScrollBar = True
    WrappingLine = False
    Editable = True
    FontSizeUnit = unitDefault
    Id = 7776822
  end
  object jButton1: jButton
    Left = 172
    Top = 153
    Width = 146
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jTextView3
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpHalfOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'Save Contact'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    FontSizeUnit = unitDefault
    OnClick = jButton1Click
    Id = 0
  end
  object jButton2: jButton
    Left = 2
    Top = 212
    Width = 316
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jEditText2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    Text = 'Show Contacts'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    FontSizeUnit = unitDefault
    Id = 4432728
  end
  object jListView1: jListView
    Left = 7
    Top = 263
    Width = 305
    Height = 96
    Visible = True
    Anchor = jButton2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    WidgetItem = wgNone
    Delimiter = '|'
    TextDecorated = txtNormal
    ItemLayout = layImageTextWidget
    TextSizeDecorated = sdNone
    TextAlign = alLeft
    HighLightSelectedItemColor = colbrDefault
    FontSizeUnit = unitDefault
    Id = 0
  end
end

Thank you!


Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #9 on: August 05, 2015, 05:11:38 pm »
Or is it possible change top, left, right and bottom of any components and my project layout in APK show like it in design layout?
Android does have AbsoluteLayout, but the default (and what LAMW implements so far AFAICS) is to use RelativeLayout. This layout scales very well with varying screen sizes instead of AbsoluteLayout which might render your app elements invisible because it's located outside the screen coordinates.

As it name says, RelativeLayout ignores absolute position (Top, Left) and size (Width, Height) properties of a control.

developing

  • New Member
  • *
  • Posts: 26
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #10 on: August 07, 2015, 04:00:20 pm »
Hi and thanks to all.

Finally I create first Android application only with use Lazarus and "LAMW" (without Eclipse).

Your tutorial is good but for newbie like me:

After install "LAMW" packages, use this way:
1-In Lazarus IDE select "Project" -> "New Project" menu, then a window shown,
2-from this window select "JNI Android Module [Lamw GUI]"
3-Press OK Button.
4-In "Android Module wizard", Enter a path on your H.D.D. into "Path to workspace [project folder]" Field.(for example d:\Projects)
5-Enter a name for your project into "[Select] Eclipse Project or [Enter] Ant Project Name:" field. (for example demo). This name is your APK project name on Android.
6-Select your project Paltform, MinSdk and TargetApi. (for example KitKat4.4, 16, 19)
7-Select Instruction and ARM Fpu. (for example ARMv7a and Soft)
8-Select Ant for Project Option, then press OK. If you select Eclipse project don't create and Lazarus IDE crash.
9-Save unit1.pas in path that showed to you.

10-Now you can use "Run" -> "[Lamw] Build APK and run" menu in Lazarus to create APK.

There was a point in my project that cannot Build APK with Lazarus:
Point: If you want use only lazarus for build APK project select Ant from Project option.
But I had choose Eclipse.

A question: When we use this way, created APK is in debug mode. Is it right? If this question is right, is there any way to create release mode project?
« Last Edit: August 07, 2015, 04:20:50 pm by developing »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #11 on: August 07, 2015, 06:41:18 pm »

Hi developing!

I will improve tutorial according yours advices!

Thany you!

Note: In "Revision 36" Ant and Eclipse projects were unifieds!!!

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

A.S.

  • Jr. Member
  • **
  • Posts: 76
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #12 on: August 07, 2015, 09:07:53 pm »
A question: When we use this way, created APK is in debug mode. Is it right? If this question is right, is there any way to create release mode project?
For now "Build APK and Run" menu item builds APK in debug mode. You can build APK in release mode manually but it should be signing:
to build  in release mode check build-release.bat in your project folder, for signing see http://developer.android.com/tools/publishing/app-signing.html#signing-manually

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #13 on: August 07, 2015, 10:51:05 pm »

some more information:

In your project folder: "readme.txt"  Item 13:

Quote
. ...before to execute "build-release.bat [.sh]"  you need execute "release.keystore.bat [.sh]"! Please, read "readme-keytool-input.txt!"
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

developing

  • New Member
  • *
  • Posts: 26
Re: Don't Compile and Run APK with Android Module Wizard
« Reply #14 on: August 08, 2015, 06:47:54 am »
Hi and thanks,

For layout designing I write a simple topic for use newbies programmers.

Question: How do we can design a custom layout that shown same in real device?
Answer   : You should use "Anchor", "PosRelativeToParent", "PosRelativeToAnchor", "LayoutParamHeight", "LayoutParamWhidth" property like below example.

Example:

1-Put a "jTextView" component on your "AndroidModule" form.
        Set "PosRelativeToParent"
                        "rpCenterHorizontal"     True
                        "rpTop"                          True

2-Put a "jButton" component on form.
        Set "Anchor" to "jTextView" (Because you should set position relative with "jTextView")
        set "PosRelativeToAnchor"
                        "raBelow"     True

3-Put a "jEditText" component on form.
        Set "Anchor" to "jButton".
        Set "PosRelativeToAnchor"
                        "raBelow"     True.

and ...

Point: Anchor setting is most important section of this design, because your component position depends on this property.

And for change width and/or height of each components you should change "LayoutParamWhidth" and/or "LayoutParamHeight".

To design your layout follow this sample for any "jComponents".

Thanks.
Best regards.
« Last Edit: August 08, 2015, 06:49:44 am by developing »

 

TinyPortal © 2005-2018