Android Question PDFium Error on compile

Peter Lewis

Active Member
Licensed User
Hi I am trying to compile the example using the files provided on the Dropbox in the inital post.
https://www.b4x.com/android/forum/threads/pdfium-pdfview2.102756/#content by @DonManfred

I am using the Lastest version of B4A along with ver 28 of com.android.support:support-v4

I am getting these compile errors. If you please can advise what I should do. i already re-installed the sdk

1613236423865.png


1613236327938.png


By but i am getting this error

B4A Version: 10.60
Parsing code. (0.00s)
Java Version: 8
Building folders structure. (0.05s)
Compiling code. (0.10s)
Compiling layouts code. (0.09s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. (0.46s)
Compiling debugger engine code. (1.03s)
Compiling generated Java code. Error
B4A line: 44
pdf.Initialize(\
javac 1.8.0_111
src\b4a\pdf\main.java:401: error: cannot access OnPageChangeListener
mostCurrent._pdf.Initialize(processBA,"PDFium");
^
class file for com.github.barteksc.pdfviewer.listener.OnPageChangeListener not found

This is the code from the Dropbox

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A pdf Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

#AdditionalJar: android-pdf-viewer.aar
#AdditionalJar: com.android.support:support-v4
#AdditionalJar: Pdfium.aar
#AdditionalJar: Pdfium.androidx.aar


Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private btnFirst As Button
    Private btnPrev As Button
    Private lblPages As Label
    Private btnNext As Button
    Private btnLast As Button
    Private glPages As Int
    Dim pdf As PdfiumCore
    Private PDFView1 As PDFView
    
End Sub


Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout1")
    pdf.Initialize("PDFium")
    File.Copy(File.DirAssets,"sample.pdf",File.DirInternal,"sample.pdf")
    Dim cfg As Configurator = PDFView1.fromUri(File.DirInternal,"sample.pdf")
    cfg.SetEventname("PDFium")
    cfg.autoSpacing(True).enableSwipe(True).pageSnap(True).swipeHorizontal(False).addOnErrorListener.addOnLoadCompleteListener.addOnPageChangeListener.addOnPageErrorListener.addOnTapListener.load

End Sub


Sub PDFium_loadComplete(pages As Int)
Log($"PDFium_loadComplete(${pages})"$)
glPages = pages
lblPages.Text = $"${glPages}"$
End Sub

Sub PDFium_onInitiallyRendered(page As Int)
    Log($"PDFium_onInitiallyRendered(${page})"$)
End Sub
Sub PDFium_onPageChanged(page As Int, TotalPages As Int)
    Log($"PDFium_onPageChanged(${page},${TotalPages})"$)
    lblPages.Text = $"${page-1}/${glPages}"$
End Sub
Sub PDFium_PageNum(page As Int)
    Log($"PDFium_PageNum(${page})"$)
End Sub
Sub PDFium_Show()
    Log($"PDFium_Show()"$)
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnFirst_Click
    PDFView1.jumpTo2(0,False)   
End Sub

Sub btnPrev_Click
    PDFView1.jumpTo2(PDFView1.CurrentPage-1,False)
End Sub

Sub lblPages_Click
    
End Sub

Sub btnNext_Click
    PDFView1.jumpTo2(PDFView1.CurrentPage+1,False)
    
End Sub

Sub btnLast_Click
    PDFView1.jumpTo2(glPages-1,False)
End Sub
 

DonManfred

Expert
Licensed User
I am getting these compile errors. If you please can advise what I should do. i already re-installed the sdk

1613236423865.png
looks like a mistake

You shouild have androidx installed.

Setup a new SDK. The new SDK download implements all AndroidX Artifacts.
 
Upvote 0
Did anyone resolve this issue? If so how?
The message is saying the library android-pdf-viewer.aar is missing. I can see that it used to be in the zip files up to version 1.02 but not after that. Does this mean that it is embedded in another library?
 
Upvote 0
Top